Possible bug with -f test

Igor Sysoev igor at sysoev.ru
Thu Jun 10 22:30:49 MSD 2010


On Thu, Jun 10, 2010 at 01:56:19PM -0400, bkirkbri wrote:

> I'm seeing a problem with static file handling when using multiple -f tests in a location block.  I could be doing something stupid, but from the debug log it looks like a bug is corrupting the pathname nginx uses to serve the static file...
> 
> The corrupt filename should be "/tmp/home.html" but is in the debug log as:
> [code]
> 2010/06/10 13:12:22 [debug] 15629#0: *3 http filename: "/tmp/home.htmlTP/1.1
> Host"
> [/code]
> 
> This is for nginx-0.7.66 compiled with: --with-http_realip_module --with-debug
> 
> Config:
> [code]
>     server {
>         listen       174.37.76.178:80;
>                 listen            10.16.10.202:80;
>         #listen       208.101.17.12:80;
>         server_name  _;
> 
>                 set $path_a             /var/www/otherpeoplespixels.com/sites/content;
> 
>                 location ~ ^/(.+\.html)$ {
>                         alias                   /tmp/$1;
>                         expires                 1m;
>                         log_not_found   off;
>                         #error_page             404 = @catalyst;
> 
>                         set $is_down no;
>                         if ( -f /tmp/$host/.down ) {
>                                 set $is_down yes;
>                         }
>                         if ( -f $path_a/$host/.grace_period ) {
>                                 set $is_down no;
>                         }
>                         if ( $is_down = yes ) {
>                                 return 503;
>                         }
>                 }
> 
>     }
> 
> }
> [/code]

The bug is in "alias/if" combination. "root" should work:

          location ~ \.html$ {
                root      /tmp;
                ...


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



More information about the nginx mailing list