Trailing Slash Redirect Loop Help

Alex Med nginx-forum at forum.nginx.org
Wed Oct 9 17:54:58 UTC 2019


Dear Francis:

Thank you for your answers.

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.

Here are the answers to your questions:

As stated before the "evil if" or try_files work well except when it comes
to directories or folders.


>>>>For clarity: can you show the config you use, and one request that
>>>>Fuses that config, and the response that you get? And, in case it is
not
>>>>Fobvious, can you show the response that you want instead?
This is with the "evil if" enable, I get the following response when it is a
directory such as the blog 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

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

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


If I disable the "evil if" and try with try_files, I get this:

To answer your question:

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

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

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

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

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273964,285830#msg-285830



More information about the nginx mailing list