Nginx Reverse Proxy Lowercase URL and some exceptions to the URL
Alex Med
nginx-forum at forum.nginx.org
Thu Oct 3 15:36:27 UTC 2019
I have the following server configuration. I have two problems that I would
appreciate if someone can tell me what I am doing wrong:
1- this location is not respected since the configuration lowercases all
uris without respecting these locations. Please note that api,
contentAssets, categoryServlet are paths, not directories or folders.
location ~
^/(api|contentAsset|categoriesServlet|DotAjaxDirector|html|dwr|dA)/{}
2. It seems that if I am in a reverse proxy I have to input the proxy
definition in every location because otherwise it does not work. Is the a
more practical way to do this?
Thank you for all your help!
Lex
Note: I have changed the proxy IP address and port for x and Is.
server {
listen 80;
server_name example.com;
##Trailing Slash in URLContent
## It doest not work on http://example.com/real-estate/cccc/
#rewrite ^/(.*)/(.*)/$ /$1/$2 permanent;
# matches any query beginning with /contentAsset or dA/ and halts
searching,
# so regular expressions will not be checked.
location ~
^/(api|contentAsset|categoriesServlet|dotAdmin|DotAjaxDirector|html|dwr|dA)/
{
proxy_pass http://xxx.xx.xx.xxx:IIII;
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;
}
## IT MUST BE FIRST TO LOWERCASE THE URI FIRST
## IF IT HAS UPPERCASE CHARACTERS
location ~ [A-Z] {
return 301 $scheme://$host$my_uri_to_lowercase;
proxy_pass http://xxx.xx.xx.xxx:IIII;
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;
}
## IT MUST BE FIRST TO LOWERCASE THE URI FIRST
## IF IT HAS UPPERCASE CHARACTERS
location ~ [A-Z] {
return 301 $scheme://$host$my_uri_to_lowercase;
}
location / {
proxy_pass http://xxx.xx.xx.xxx:IIII;
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;
}
}
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285780,285780#msg-285780
More information about the nginx
mailing list