-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
redirect /.well-known/ to correct port in nginx #899
Comments
@josh4trunks Do you have an idea for this? This is basically then the case when there is a reverse proxy infront of Nginx as well :/ |
I'm confused what a proxy in front of NGINX has to do with return 301. Isn't a return 301 pretty much handled by the client doing a new request for the updated URI. @macmeck does this work for your scenario? |
It is because the Nginx port is a different one, than the one of the reverse proxy in front of it. Thus the redirect goes to the port of Nginx instead of the reverse proxy. See nextcloud/server#11789 for more details. |
ahh, ok makes sense. i assume handcoding it like i propose resolves this |
Yes - was reported to solve the issue in the original and linked on in the server repo. |
@josh4trunks , yes, hardcoding the redirect port works. But is there a way to do this dynamically? |
@macmeck if there is a reverse proxy in front of NGINX, NGINX would not know what port that reverse proxy is using. There is the PROXY Protocol, which allows the reverse proxy to forward additional information about the client connection including client IP:port and server (reverse proxy) IP:port. NGINX does support this, but currently does not save the server IP or port to a variable. See a feature request here. There are ways to hack this, like forwarding an HTTP header from the reverse proxy, then mapping that in NGINX. This is protocol specific, and not as efficient as if we had full PROXY Protocol support.
|
Hm, I just realized that the setup is even worse. Port forwarding is already done by the router upfront. So the machine running nginx and Nextcloud already gets the request on port 443. So to fix this, we need to find out the port the client used in its initial request. |
@macmeck I'm not sure what you are asking me to help with? I though I was helping with deficiencies with the documentation, but it sounds like you need help with your specific setup. |
Another use case: I use Nginx Reverse Proxy with Apache2 as backend. Nginx talks to the internet on port 443 but on port 80 with the Apache backend. I tried adding the 301 Redirect stuff suggested in issues here on Github in the Apache2 vhost on the backend, but it didn't help. I'm very interested in how to solve this issue. |
@enoch85 We are talking about the NGINX configuration documentation here. If you are doing your redirect in Apache2 that wouldn't be using the NGINX docs. Also, I am fairly certain my earlier post mentioning PROXY Protocol could be implemented with NGINX > Apache2. With PROXY Protocol Apache2 could always know what port the client is connecting to without any tricks. |
Yeah, never was an issue before. Seeing this in my "Overview" since 14.0.something. |
@enoch85 Your redirect is in NGINX or Apache2? You already can solve it using hardcoded ports in NGINX. I can't really help with Apache2, I'm pretty much a n00b at apache. |
@josh4trunks This is how it looks like basically: Nginx listens:
forwards to Apache2:
I tried setting this in the Apache2 vhost:
|
@enoch85 And the issue is redirts to /.well-known/* go to port 80? |
@josh4trunks Nope, sorry :( Thanks for trying though. I tried http as well and no avail. I don't know what the issue is, everything is working correctly, but the status checks says that it doesn't. |
ohh, if it's just the status check, I don't know exactly how that works. But I assume the PHP Nextcloud code needs to know what protocol (http/https), domain, and port to check. Maybe it doesn't know. |
Well, the issue for me is that check won't work then as it will always produce an error due to the fact that the proxy runs on 443 and the backend on 80. |
Don't we have this issue always if Nextcloud listens on standard http/https ports but sits behind a router that does port forwarding? |
This issue is solved for me with this. |
@enoch85, I think I do not fully understand the solution here. Do you suggest to replace the dynamic $scheme by static https:// ? In this case, this is not a working solution for the issue since Nextcloud is indeed accessed via https (no https offloading upfront) which is correctly being resolved by $scheme. The issue behind a router that does port forwarding will be that from outside the system needs to be accessed via a non-standard port which is not inserted in the redirect by now. |
Same promblem here. I use the 15.0 RC2 and recieve the message ".well-known" problems. |
I guess the hardcoding still makes sense, or am I completely wrong? See #1114 |
I've NC 17 on nginx 1.17.1 I'm behind a proxy atm; this is just a simple site. I've changed my nginx config
still, currrently,
|
@pgnd, I have a similar setup (not proxy but using NAT dest).
|
Currently, the documentation for service discovery in nginx proposes to redirect /.well-known/ to proper paths.
This only works for the standard ports but fails if Nextcloud runs on a different port. A dynamic port parameter should be added to the redirect but I did not yet find out how.
The text was updated successfully, but these errors were encountered: