404 then upstream timeout

Eden Li eden at mojiti.com
Fri Mar 7 05:53:55 MSK 2008

Hi all,

I'm running into a strange issue with nginx upstreaming to a varnish  

When I POST to a specific URL with invalid parameters, I want the call  
to return a 404.

However, nginx returns 504 after a 60ish second timeout.

I notice in my logs that $upstream_status is returning 2 values "404 :  
$upstream_response_time is "0.026 : 60.000"

If I hit varnish directly, the call returns immediately with the  
proper 404 response.

Tracing varnish logs during this call shows that only a single request  
is made against, even though $upstream_status seems to be returning 2  

Here's the basic config (salient bits only)

upstream varnish {; }

server {
   proxy_redirect false;
   proxy_max_temp_file_size 0;
   proxy_next_upstream off;
   proxy_read_timeout 60;
   proxy_intercept_errors on;

   error_page 404 /404.html;
   error_page 500 /500.html;

   location / {
     proxy_pass http://varnish;

This is nginx/0.5.32.  Does anyone know why nginx seems to be making 2  
calls, when it should only be returning 404 immediately?


More information about the nginx mailing list