Log response header from upstream
Maxim Dounin
mdounin at mdounin.ru
Mon Nov 7 10:19:03 UTC 2011
Hello!
On Mon, Nov 07, 2011 at 06:42:09AM +0100, Kamil Gorlo wrote:
> Yeah, I have tried this, but this way non x-accel-redirect requests must be
> handled in old way which means I have to use 2 fields in access log. Is
> there any way to use only one field?
E.g. you may use different log format for internal location.
Maxim Dounin
> 06-11-2011 22:15 użytkownik "Maxim Dounin" <mdounin at mdounin.ru> napisał:
>
> > Hello!
> >
> > On Sun, Nov 06, 2011 at 09:48:08PM +0100, Kamil Gorlo wrote:
> >
> > > Hi,
> > >
> > > I have some problem with access log combined with X-Accel-Redirect
> > > requests. In my case I have Nginx set up as load-balancer to group of
> > > application servers. These servers return some special header in every
> > > request - I need to log value of this special header (lets call it
> > > 'X-user') in access log - also I do not want to expose this header to
> > > the world (proxy_hide_header helps here).
> > >
> > > Everything seems to work, but when there is X-Accel-Redirect request I
> > > have empty field in access log because of subrequest
> > > ($upstream_http_x_special is cleared because of subrequest, if I
> > > understand this mechanism correctly). How to make this work for every
> > > request?
> > >
> > > Here is my config:
> > >
> > > http {
> > > log_format extended '$request $upstream_http_x_user';
> > > access_log /var/log/nginx/access.log extended;
> > >
> > > ...
> > >
> > > server {
> > > listen 80;
> > >
> > > location / {
> > > proxy_pass http://backend;
> > > proxy_hide_header X-User;
> > > }
> > >
> > > location /files {
> > > internal;
> > > proxy_pass http://filestore;
> >
> > Workaround is to use
> >
> > set $x_user $upstream_http_x_user;
> >
> > here (and to log $x_user instead).
> >
> > > }
> > > }
> > > }
> >
> >
> > Maxim Dounin
> >
> > _______________________________________________
> > nginx mailing list
> > nginx at nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list