<p>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? </p>
<div class="gmail_quote">06-11-2011 22:15 użytkownik "Maxim Dounin" <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> napisał:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<br>
On Sun, Nov 06, 2011 at 09:48:08PM +0100, Kamil Gorlo wrote:<br>
<br>
> Hi,<br>
><br>
> I have some problem with access log combined with X-Accel-Redirect<br>
> requests. In my case I have Nginx set up as load-balancer to group of<br>
> application servers. These servers return some special header in every<br>
> request - I need to log value of this special header (lets call it<br>
> 'X-user') in access log - also I do not want to expose this header to<br>
> the world (proxy_hide_header helps here).<br>
><br>
> Everything seems to work, but when there is X-Accel-Redirect request I<br>
> have empty field in access log because of subrequest<br>
> ($upstream_http_x_special is cleared because of subrequest, if I<br>
> understand this mechanism correctly). How to make this work for every<br>
> request?<br>
><br>
> Here is my config:<br>
><br>
> http {<br>
> log_format extended '$request $upstream_http_x_user';<br>
> access_log /var/log/nginx/access.log extended;<br>
><br>
> ...<br>
><br>
> server {<br>
> listen 80;<br>
><br>
> location / {<br>
> proxy_pass <a href="http://backend" target="_blank">http://backend</a>;<br>
> proxy_hide_header X-User;<br>
> }<br>
><br>
> location /files {<br>
> internal;<br>
> proxy_pass <a href="http://filestore" target="_blank">http://filestore</a>;<br>
<br>
Workaround is to use<br>
<br>
set $x_user $upstream_http_x_user;<br>
<br>
here (and to log $x_user instead).<br>
<br>
> }<br>
> }<br>
> }<br>
<br>
<br>
Maxim Dounin<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div>