Welcome! Log In Create A New Profile

Advanced

Re: proxy_intercept_errors and logging

Maxim Dounin
January 13, 2012 05:22PM
Hello!

On Fri, Jan 13, 2012 at 02:47:00PM -0500, mikeyk wrote:

> Hi there,
>
> We have nginx proxying to a bunch of django upstreams.
>
> When those upstreams throw an error, we use proxy_intercept_errors to
> show a custom page. The problem is that this causes those 500s to be
> logged into the global access_log, rather than the access_log specified
> for that location. Here is a (reduced) example:
>
> # at the server
> access_log /logs/nginx/access.log accesslogformat;
> proxy_intercept_errors on;
> location ~ ^/oauth.*$ {
> proxy_pass http://appservers;
>
> access_log /logs/nginx/app.log applogformat;
> }
>
> Is there a way to get errors to log to the app.log in this case, even
> with proxy_intercept_errors to on? Right now we get all the 500s in the
> access.log.

Requests are logged in context of a location where their
processing ends. This means that after error_page redirection
they will logged in the location where error_pages are processed.

If you want them to be logged to the same app.log, you need to
define location for errors with the same logging. To avoid mixing
logs with normal errors, you may want to define separate
error_page's for your apps. Something like this should work:

location /oauth {
proxy_pass ...

proxy_intercept_errors on;
error_page 502 504 /errors_oauth/5xx.html

access_log /path/to/app.log applogformat;
}

location /errors_oauth/ {
alias /path/to/errors/;
access_log /path/to/app.log applogformat;
}

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy_intercept_errors and logging

mikeyk January 13, 2012 02:46PM

Re: proxy_intercept_errors and logging

Maxim Dounin January 13, 2012 05:22PM

Re: proxy_intercept_errors and logging

mikeyk January 13, 2012 06:27PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 209
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready