Forum: NGINX error_page not redirecting as expected

D4fbc4a500659809c15d90e4cf6e8cf7?d=identicon&s=25 Maxim Khitrov (Guest)
on 2012-10-26 14:50
(Received via mailing list)
Hello,

I'm sure it's something simple, but I don't know where the problem is
in the following configuration:

server {
  listen 80;
  server_name example.com;
  root /path/to/webroot;

  error_page 404 /status/404;

  location / {
    try_files $uri @dynamic;
  }

  location @dynamic {
    include fastcgi_params;
    fastcgi_pass unix:/tmp/myapp.sock;
    fastcgi_intercept_errors on;
  }
}

I have some static files (css, js, etc.) under webroot that are served
by nginx. Everything else should be sent to @dynamic. If the initial
@dynamic request is answered with 404, I want nginx to make a second
request to @dynamic with the path set to /status/404.

What happens instead is that if the initial request receives a 404
response from the FastCGI responder, nginx serves the default 404 Not
Found page (not even the content returned by @dynamic) instead of
rewriting the request to /status/404. Opening /status/404 directly
works just fine.

Where did I make a mistake? There is nothing in the error log to give
me any hints.

- Max
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.