46

I am using rewrite and proxy_pass and I am having some intermittent issues with the site I am proxying said rewrites too. Is there a means to log the proxy activity so I that I can debug this problem?

dgw
  • 12,645
  • 11
  • 55
  • 51
hinder90
  • 541
  • 1
  • 4
  • 7

1 Answers1

70

I am not an expert, but having the same problem here what I did in my nginx.conf :

log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';

access_log  /var/log/nginx/access.log upstreamlog;

The first line define a new format, and then you tell access_log to use it

mahemoff
  • 41,502
  • 34
  • 146
  • 213
mkx
  • 701
  • 5
  • 3
  • Wait, does this change the default `access.log` too? Do I need to define this inside the proxy/upstream location? – Xeoncross Jul 14 '14 at 18:17
  • 4
    @Xeoncross the log_format must be in the `http {}` section, however you can define the `access_log` directive inside a `location` block (see the [context](http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log)). – bufh Aug 19 '14 at 08:42
  • I'm basing my jenkins.conf on the official docs but I get these variables always void. Would you give a look at this gist please? https://gist.github.com/tuxerrante/b417d54eabc7a870c3bbb97dc9494420 – tuxErrante Feb 09 '21 at 17:59