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

Maxim Dounin mdounin at mdounin.ru
Mon Oct 11 11:29:53 MSD 2010


Hello!

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;
>             }

This is known issue with "if".  Avoid using "if", use two separate 
locations instead.

http://wiki.nginx.org/IfIsEvil

Maxim Dounin



More information about the nginx mailing list