-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Add nginx reverse proxy support #1163
Comments
All of that is possible with the current state. |
so, is this something where you would just replicate the existing docs on nginx on another nginx instance? i was trying to essentially proxy the nginx instance on the pi to my external nginx box. |
i dont think it is, or its not obvious how to do this. even trying to use the nginx docs on a different instance of nginx (not on the same site) its failing to find the files: lets say i have http://voron24/ which is mainsail and working just fine. i have another instance of nginx that is my proxy, running on 192.168.1.xxx. this is exposed to the internet via port forwarding, has auth in front of it, ssl, etc. i want to set up http://www.publicsite.com/voron24 and have it proxy to http://voron24/ but i have never been able to get this working, as it would always attempt to at least load the websocket from the root of the app vs the actual url. this is where the whole urlbase thing comes into play, ala Radarr, so that all URLs essentially get rewritten with this base. i think this is where things are breaking, at least in the scenario above. unless i am missing something, i dont see how "this already works" when mainsail is on the pi and nginx is serving files from there, so any guidance, or an acutal working reverse proxy block, would be awesome. working example for radarr location /radarr {
} what should be possible is to replicate this, but change the proxy_pass value to http://voron24/ (in my case), but it does not. things start loading, and then the websocket, trying to be loaded/contacted from /, fails, which then kills things location /voron24/websocket { but this did not work. i even tried goofy stuff such as:
but of course, the file names change, so that wont work. please prove me wrong here =) if this is possible in the current state of things, please provide a working example like the one above for /radarr |
having a base url setting simplifies having sub folder based reverse proxies. server name voron24.domain.com works OOB because it uses the / context for stuff. |
Except for webcam access, or at least it didn't when I did the subdomain
approach.
One, or both, options should work ideally
…On Fri, Nov 25, 2022, 8:14 AM vajonam ***@***.***> wrote:
having a base url setting simplifies having sub folder based reverse
proxies. server name voron24.domain.com works OOB because it uses the /
context for stuff.
—
Reply to this email directly, view it on GitHub
<#1163 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABARKJXXQ26JR25UHEARDCLWKC3TZANCNFSM6AAAAAASGSWOVE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@EricZimmerman Obviously, this issue is still open but I wonder if you made any further progress on your configuration? This is exactly my setup and I'm having similar struggles. Thanks! |
Nope. I gave up. Not worth the hassle without basic support for this imo. I just use zerotier |
Can you post it? |
Sure thing. All its missing is Mainsail having native authentication to remove the basic nginx authentication. server {
listen 80;
server_name mainsail.baguette.fr;
location ~ /\.well-known/acme-challenge {
root /var/www/html;
allow all;
}
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name mainsail.baguette.fr;
add_header Strict-Transport-Security "max-age=31536000";
ssl_certificate /etc/letsencrypt/live/mainsail.baguette.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mainsail.baguette.fr/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mainsail.baguette.fr/chain.pem;
access_log /var/log/nginx/mainsail.baguette.fr.access.log;
error_log /var/log/nginx/mainsail.baguette.fr.error.log error;
client_max_body_size 100m;
auth_basic "";
auth_basic_user_file /etc/nginx/.htpasswd;
location /nginx_status {
stub_status on;
access_log off;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://votre_ip:80;
}
location /websocket {
proxy_pass http://votre_ip:80/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 86400;
}
} |
Has anyone had any luck getting the webcam to be viewable through the proxy? I get CORS error. I have everything else working though. |
@jbyerline depends on which cors errors you get. But I think you get cors errors from the API (Moonraker). You have to add your domain/url to cors_domains in your moonraker.conf. |
The configuration I posted earlier should work. It shouldn't work if you are using crownest v4 and webrtc streaming, for that I am waiting for the update of the library used by crownest to allow remote ICE. |
This configuration works well, but when i use port forwarding from the nginx proxy by the router and if i don't want to use the external 443 port (another service already occupied it) camera streaming is not possible, because the camera url is composed despite current used port.
|
@dictor93 this is a browser limitation. If you want to use a Https Webinterface, all other connections have also to be secure! You cannot connect to an insecure webcam with a secure Webinterface. |
What nonsense are you talking about? Data from the camera is received through the endpoint of the same server on which Mainsail works and to which a reverse proxy is made. It's just that if I'm using a different port than 443, I want the path to the camera endpoint to include that port as well and not refer to 80/443. I compiled the frontend with the changes I mentioned above and have no problems with the camera. But for this you will have to give up updates. Or build the frontend with your own edits every time. I just suggested making it part of the codebase |
Hi, I'd like to work on this issue (or similar). As I see it, the problem is not adding "reverse proxy support" specifically for nginx but rather enable mainsail to configure a
and so on. |
I brought this up as well and was told it's way too much work but that was 2 years ago |
Not quite what is being asked for subpath reverse proxying, but I accomplished multiple cameras on a single domain. I ended up using a single Mainsail instance for multiple printers using the following Caddy config:
along with this Mainsail config
And the cameras are included as The camera trick allows a single camera entry to work on both the shared domain and on the printer directly for things like the Moonraker-homeassistant integration |
@PSandro hey! I appreciate your interest in an implementation. If you mean the There was already a PR on this topic, but unfortunately, it was not completed: #1359 if you have any questions, please ping me or contact me on discord. |
There should be a possibility to dynamically detect the actual base path via the experimental vite base options: |
@PhilippMolitor pay attension, that vite is only a "build framework". so it only runs during the build/release process. if i read this description:
it sounds also, that it only build the url during the build process and not "live". |
I know, I am using vite a lot myself. What I am saying is that you could inject your own function there, wrapping the existing one, reading a global variable defined (for example) in index.html. This way you could use the build process to make it handle base path detection at runtime depending on some variable. |
We try to store all non "Moonraker instance related variables" in the config.json file and there i have the first problem, because the path/url cannot be found without the base_url. this file also has the background, because you can exclude it from the Moonraker update_manager. i have now read the guide again carefully, but unfortunately i still can't recognize any “dynamic update” after the build process. to me it looks like a hardcoded url made after the build. |
Requested feature:
I tried for hours to get this working with nginx to no avail. Most apps seem to want a urlprefix for things to work and this was my issue I believe since the app always looked at the root of the url for various files.
I tried rewrite rules and a bunch of other things. Other examples are sonarr and radar, among others
Solves the following problem:
Allow for security to be managed in nginx including SSL, authentication and 100 other things.
Additional information:
No response
The text was updated successfully, but these errors were encountered: