Welcome! Log In Create A New Profile

Advanced

Re: Trailing Slash Redirect Loop Help

Francis Daly
October 09, 2019 05:34PM
On Wed, Oct 09, 2019 at 01:54:58PM -0400, Alex Med wrote:

Hi there,

> Here is the full configuration with reverse proxy, pagespeed,and
> lowercasing. It all
> works well, but now that I incorporated removing the trailing slash it
> brought up new
> issues: https://pastebin.com/keQ239D4. Let me know if you prefer that I
> post the configurations
> in the post.

Thanks for this.

Some of this configuration is not "stock nginx", but I guess that the
extra modules do not affect the issue here.

It would be convenient for history here, to have the config here; but
the relevant part is basically the part shown in the previous mail.

Most requests eventually use a proxy_pass to an upstream server.


> This is with the "evil if" enable, I get the following response when it is a
> directory such as the blog directory:

I suspect that there may be an interpretation issue here.

When I read "the blog directory", I understand something along the lines
of "/usr/local/nginx/html/blog/index.html exists as a file that nginx
can see".

I now suspect that you intend something like "the upstream server
considers it to be a directory".

> curl -i http://example.com/blog/
> HTTP/1.1 301 Moved Permanently
> Server: nginx
> Date: Wed, 09 Oct 2019 15:06:04 GMT
> Content-Type: text/html
> Content-Length: 178
> Location: http://example.com/blog
> Connection: keep-alive

That's from nginx; your config says "if the request ends in / and does
not represent a directory on this filesystem, redirect to no-slash".

> curl -i http://example.com/blog
> HTTP/1.1 301
> Server: nginx
> Date: Wed, 09 Oct 2019 15:06:48 GMT
> Content-Length: 0
> Connection: keep-alive
> Location: /blog/
> Cache-Control: s-maxage=10

That's from your upstream server. Presumably it has decided that "/blog
refers to a directory as far as it is concerned; please request /blog/
instead".

And there is your infinite loop.

So I guess the next question is: what response do you want from nginx?

In this specific case: when you request /blog/, how would you like nginx
to handle that request?

And in your answer, also consider: how might nginx possibly be able
to tell that you want the request handled differently from a request
for /file/?

> >>Does the proxy_pass upstream
> >>share the same filesystem as this nginx?
> No, they do not share the same file system.

"if -d" looks on the filesystem. try_files looks on the filesystem.

If the filesystem does not contain the information on whether "this"
thing is a directory or not, looking on the filesystem will not be able
to give a useful answer.


So, what specific problem are you trying to solve?

If you remove the "remove the slash" configuration from nginx, is there
one request that gets a response that you do not want?

Perhaps fixing the handling of *that* request will get you to a config
that does what you want.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Trailing Slash Redirect Loop Help

Alex Med April 28, 2017 10:27AM

Re: Trailing Slash Redirect Loop Help

steveh April 28, 2017 10:42AM

Re: Trailing Slash Redirect Loop Help

Alex Med April 28, 2017 10:48AM

Re: Trailing Slash Redirect Loop Help

steveh April 28, 2017 11:36AM

Re: Trailing Slash Redirect Loop Help

Alex Med April 28, 2017 11:43AM

Re: Trailing Slash Redirect Loop Help

steveh April 28, 2017 11:48AM

Re: Trailing Slash Redirect Loop Help

Alex Med April 28, 2017 12:52PM

Re: Trailing Slash Redirect Loop Help

steveh May 01, 2017 06:42PM

Re: Trailing Slash Redirect Loop Help

Alex Med May 10, 2017 10:43AM

Re: Trailing Slash Redirect Loop Help

Francis Daly April 29, 2017 08:36AM

Re: Trailing Slash Redirect Loop Help

Alex Med May 10, 2017 11:10AM

Re: Trailing Slash Redirect Loop Help

Francis Daly May 12, 2017 05:26PM

Re: Trailing Slash Redirect Loop Help

Alex Med October 06, 2019 12:24PM

Re: Trailing Slash Redirect Loop Help

Francis Daly October 08, 2019 06:48PM

Re: Trailing Slash Redirect Loop Help

Alex Med October 09, 2019 11:22AM

Re: Trailing Slash Redirect Loop Help

Francis Daly October 09, 2019 05:34PM

Re: Trailing Slash Redirect Loop Help

Alex Med October 14, 2019 11:04PM

Re: Trailing Slash Redirect Loop Help

Alex Med October 14, 2019 11:06PM

Re: Trailing Slash Redirect Loop Help

Francis Daly October 15, 2019 10:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready