Welcome! Log In Create A New Profile

Advanced

Re: Trailing Slash Redirect Loop Help

April 28, 2017 11:36AM
If I understand what you're trying to do correctly, then I think you
want something like:

# Ensure no tailing slashes
rewrite ^/(.*)/$ /$1 permanent;

location @upstream {
proxy_pass https://xxxx:xportNumber;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_redirect off;
}

location / {
try_files $uri $uri/ @upstream;
}

This will accept /wibble/ and rewrite it to /wibble (this will be passed
back to the client which will then re-request /wibble) when the new
request rewritten comes it the server will still look for local matches
of /wibble (the file) and /wibble/<index files> (the directory) when
searching for the content to serve and if not found will pass the
request to your upstream server.

Regards
Steve

On 28/04/2017 15:48, Alex Med wrote:
> Steveh:
>
> Thank you for your reply.
>
> So what you are suggesting me to do is something like this:
>
> location / {
> try_files $uri $uri/ @rewrite;
> }
>
> location @rewrite {
> rewrite ^/(.*)/$ /$1 permanent;
> }
>
> Put try files inside the location block and create a new block with the
> rewrite?
>
> Thank you for the clarification!
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273964,273966#msg-273966
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
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: 110
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready