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
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to