nginx's bug(alias and $request_uri to conflict)

Igor Sysoev igor at sysoev.ru
Mon Oct 11 09:06:02 MSD 2010


On Mon, Oct 11, 2010 at 10:46:28AM +0800, Simon Liu wrote:

> thanks!
> 
> my nginx version is 0.8.52, index.html in /home/my_name/tools/nginx/html/
> , this is my nginx config:
> 
>  worker_processes  1;
> 
> error_log  logs/error.log  debug;
> events {
>     worker_connections  1024;
> }
> http {
>     include       mime.types;
>     default_type  application/octet-stream;
>     expires         1y;
>     sendfile        on;
>     server {
>         listen       8080;
>         server_name  localhost;
>         location ~*  ^/html/(.+\.html)$ {
>             alias   /home/my_name/tools/nginx/html/$1;
>             if ($request_uri ~ \.(html|htm|shtml)$) {
>                 expires     1h;
>             }
>         }
>         error_page   500 502 503 504  /50x.html;
>         location = /50x.html {
>             root   html;
>         }
>     }
> }

1) wiki.nginx.org/IfIsEvil

2) location ~*  ^/html/(.+\.html)$ {
      alias   /home/my_name/tools/nginx/html/$1;

   it's better to change to just

   location ~*  ^/html/.+\.html$ {
      root   /home/my_name/tools/nginx;

3) ...|shtml)$ is not matched by \.html)$

4) regex is usele here, so

         location  /html/ {
             root   /home/my_name/tools/nginx;
             expires     1h;
        }


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list