Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med nginx-forum at forum.nginx.org
Thu Oct 3 17:03:01 UTC 2019


I also would like to add that when I access:  example.com/API/ it is
lowercased to example.com/api/.  According to my configuration it should
not.  So it means location #1 is not working properly.



Alex Med Wrote:
-------------------------------------------------------
> Dear Francis:
> 
> Here are the answers to your questions.  Thank YOU for helping!
> 
> The location block are in the following order:
> 
> Location #1
> location ~
> ^/(api|contentAsset|categoriesServlet|DotAjaxDirector|html|dwr|dA)/
> {}
> 
> Location #2 ----> This location does the lowercasing
> location ~ [A-Z] { return 301 $scheme://$host$my_uri_to_lowercase;}
> 
> Location #3
> location /{}
> 
> Everything is lowercased.  So I want some paths to be untouched. So I
> created location #1 to exclude some paths from lowercasing.  The
> problem is that 
> in some URLs containing the paths above are lowercased.  For example:
> /dwr/interface/CategoryAjax.js, /dwr/interface/HostAjax.js are
> lowercased.
> Also, /html/images/languages/gh_TW.gif
> 
> Any help will be appreciated!
> 
> 
> 
> Note: The function definition for $my_uri_to_lowercase is inside my
> http definition, here is a copy of it:
>   ##
>         ## URL REWRITE FUNCTION:  LOWERCASE ALL URIs
>         ## START
> 
>         perl_set $my_uri_to_lowercase 'sub {
>          my $r = shift;
>          my $uri = $r->uri;
>          $uri = lc($uri);
>          return $uri;
>          }';

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



More information about the nginx mailing list