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

Disable absolute_redirect #82

Merged
merged 1 commit into from Jan 18, 2022
Merged

Disable absolute_redirect #82

merged 1 commit into from Jan 18, 2022

Conversation

jlxip
Copy link
Contributor

@jlxip jlxip commented Jan 14, 2022

If this is a docker image, then it is safe to assume that most of the time it will be used in a container behind another nginx proxy.

Let's consider the scenario:

internet -> nginx https (443) -> docker (local port, let's say 8001) -> this container (8080)

Let's now consider the access:

https://example.com/pub

Assuming pub is a directory, nginx will try to add the slash at the end, and the following redirect will take place:

https://example.com/pub -> http://example.com:8080/pub/

(Please do try it)

Both the protocol (https -> http) and the port (443 -> 8080) change, leaving the site unaccessible. A solution would be to disable port_in_redirect in the nginx configuration. That change produces:

https://example.com/pub -> http://example.com/pub/ -> https://example.com/pub/

(Please try it)

The site is now accessible, but there's an extra redirect because of the protocol change. absolute_redirect leaves both the protocol and the port behind so a single redirect takes place.

https://example.com/pub -> /pub/ (which the browser interprets as https://example.com/pub/)

Even though the nginx.conf file can be changed by just binding another file to it, I think it would be better if the default config took this into account.

@TrafeX
Copy link
Owner

TrafeX commented Jan 18, 2022

Hi @jlxip,

Thank you for your contribution, that indeed looks like a sane default 👍

@TrafeX TrafeX merged commit 238f3db into TrafeX:master Jan 18, 2022
@maggie44
Copy link
Contributor

maggie44 commented Feb 7, 2022

@jlxip do you know how this differs to port_in_redirect?

@jlxip
Copy link
Contributor Author

jlxip commented Feb 8, 2022

@Maggie0002 🤨 I literally gave an explanation above

@maggie44
Copy link
Contributor

maggie44 commented Feb 8, 2022

Ha, yes, that was stupidly vague of me.

I have been using this image but not behind a proxy as how you have detailed here. This whole time I have mounted a config file and been using port_in_redirect to resolve an issue. I am trying to grasp the technical distinctions between the two under the hood to understand the implications of no longer mounting my config file and using this default config file with the absolute_redirect. Is it purely the different redirect strategy of one less hop? I am not in the category of most people in terms of the behind a proxy, and the fact you mentioned what users likely default behaviour would be to rationalise the change I’m trying to gauge the implications for those who are ‘not most people’.

Nginx docs as always are rather vague on the matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants