Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webui: Implement support for reverse proxies #2343

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

psyke83
Copy link
Collaborator

@psyke83 psyke83 commented Apr 1, 2024

Description

  • Add "web_ui_address" option to UI Network tab.
  • Add tray icon link handling, with proxy connectivity check to decide which link to open.
  • Add reverse proxy suggestion to Setup document as a hint to circumvent self-signed SSL warnings.

Screenshot

Screenshot_20240403_151525

Issues Fixed or Closed

Resolves #1034

N.B.: this PR doesn't implement the stated proposal in title of #1034 (insecure http support in Sunshine), but instead enhances the url handler to use a proxied address if set by the user, and add some basic documentation on reverse proxying. A reverse proxy should typically proxy the secure https://<host>:47990 address, and self-signed certs shouldn't cause issues (if using Nginx Proxy Manager, at the very least).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 3.84615% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 6.50%. Comparing base (2da6fb0) to head (4c6f5b8).

Additional details and impacted files
@@            Coverage Diff             @@
##           nightly   #2343      +/-   ##
==========================================
- Coverage     6.50%   6.50%   -0.01%     
==========================================
  Files           85      85              
  Lines        18382   18406      +24     
  Branches      8348    8355       +7     
==========================================
+ Hits          1196    1197       +1     
+ Misses       16136   16081      -55     
- Partials      1050    1128      +78     
Flag Coverage Δ
Linux 4.41% <0.00%> (-0.01%) ⬇️
Windows 2.00% <0.00%> (-0.01%) ⬇️
macOS-12 8.72% <4.16%> (-0.02%) ⬇️
macOS-13 8.06% <4.00%> (-0.01%) ⬇️
macOS-14 8.38% <4.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/config.h 0.00% <ø> (ø)
src/config.cpp 5.33% <50.00%> (-0.02%) ⬇️
src/entry_handler.cpp 5.36% <0.00%> (+0.54%) ⬆️
src/httpcommon.cpp 4.06% <0.00%> (-0.48%) ⬇️

... and 15 files with indirect coverage changes

@psyke83 psyke83 force-pushed the reverse_proxy_support branch 2 times, most recently from 7e2b222 to eaca72d Compare April 1, 2024 04:15
docs/source/about/advanced_usage.rst Show resolved Hide resolved
Comment on lines 781 to 784
if (!config::nvhttp.web_ui_address.empty()) {
BOOST_LOG(info) << "Configuration UI available at ["sv << config::nvhttp.web_ui_address << "]"sv;
}
BOOST_LOG(info) << "Configuration UI available at [https://localhost:"sv << port << "]"sv;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make an array of the addresses it's available at, and only have one log message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this, I have some reservations about the PR related to privacy: users may not want their reverse proxy address to be exposed when sending logs.

In my case, I use a reverse proxy for all my home services with the intention not to expose anything outside of my LAN, but I'm forced to use a DNS AAAA record, as my ISP uses DNS spoofing to block A records that refer to a private network space. I use the reverse proxy for multiple services, but none are exposed to the external network, and I'd prefer not to be leaking the address online unnecessarily.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point... I think it's safe to only log the localhost address.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backed out the logging, but keep in mind that the proxy address will be exposed by open_url() & resolve_command_str() invocations.


if (!config::nvhttp.web_ui_address.empty()) {
// Don't append internal TCP port as port is mapped by reverse proxy
url = config::nvhttp.web_ui_address;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to use the reverse proxy address from the server itself?

Copy link
Collaborator Author

@psyke83 psyke83 Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean via the link handler as used by the tray icon on the host? At least in my case, yes. The main benefit of using the reverse proxy for Sunshine in particular is so that I can use my own valid SSL cert that's managed on a different machine than the Sunshine host. Having the tray icon open the self-signed site means I need to deal with the SSL warnings each time, which cancels out most of the benefit of using the proxy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this should be optional? In the event of an internet outage, people won't be able to open ui via the tray icon.

Or fallback to the localhost address if the proxy address is unreachable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented the latter suggestion as it seems to make the best sense and keep things simpler.

@psyke83 psyke83 force-pushed the reverse_proxy_support branch 3 times, most recently from 2a70c10 to bce31e3 Compare April 3, 2024 03:49
Comment on lines +203 to +204
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); // ignore self-signed cert
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); // ignore self-signed cert
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines will let the function detect a proxied or other address that is still using a self-signed cert. For example, you can test functionality without a reverse proxy by setting the url to https://sunshinehost:47990.

It might be OK to leave this here, but if we want to enforce valid SSL checking, I can remove the lines and perhaps add a note that a valid SSL cert will be required to the docs.

@psyke83 psyke83 force-pushed the reverse_proxy_support branch 2 times, most recently from 23758c0 to 3a49fef Compare April 3, 2024 04:32
<!-- Web UI Address -->
<div class="mb-3">
<label for="web_ui_address" class="form-label">{{ $t('config.web_ui_address') }}</label>
<input type="text" class="form-control" id="web_ui_address" placeholder="https://localhost:47990" v-model="config.web_ui_address" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change the placeholder to a reverse proxy example? If yes, is https://example.com:80/sunshine appropriate here (and elsewhere)? I'm asking because the External IP entry is using an example IP range, so I assume users won't get confused that the placeholder is only an example and not the actual default when unset.

* Add "web_ui_address" option to UI Network tab.
* Add tray icon link handling, with proxy connectivity check to decide which link to open.
* Add reverse proxy suggestion to Setup document as a hint to circumvent self-signed SSL warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants