This is my first post ever. Hopefully, I'll be able to explain my problem thouroughly.
I have an Nginx config that redirects my.domain.com/avocado to my.domain.com/avocado/ (with a slash in the end). This also redirect subpaths (end with a slash) after the /avocado path like:
my.domain.com/avocado/banana --> my.domain.com/avocado/banana/ my.domain.com/avocado/banana/apple --> my.domain.com/avocado/banana/apple/
Now, we noticed that URLs with "/--" as the last subpath (example: my.domain.com/avocado/banana/apple/--) is not redirecting correctly. It should redirect to my.domain.com/avocado/banana/apple/ (append a slash to the last subpath)
I think this is regex stuff too but I have no idea how to correctly do it. Would you guys suggest any regex? Thank you!
server {
server_name my.domain.com;
location /avocado {
resolver 10.1.0.2 valid=60s;
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$1 permanent;
}
rewrite ^([^.]*[^/])$ https://$server_name$1/ permanent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://$upstreamserver$request_uri;
}
}