ROIR
ROIR

Reputation: 89

how to expose custom header on nginx

Our https requests sending new header "X-XSRF-TOKEN" to the Nginx. Some time the header coming "= null" to my backend servers.

MY question, is there any option to see this header in my access.log?

how can i make sure that the Nginx is not blocking the header.

I have to say 98% from the request, they are coming with correct value.

Thanks!

Upvotes: 4

Views: 11711

Answers (1)

Ivan Shatsky
Ivan Shatsky

Reputation: 15687

Of course, you can define any custom access log format and use any of the available nginx internal variables. The default nginx log format is:

log_format  combined  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

Just define a new access log format and add the $http_x_xsrf_token variable to it:

log_format  debug     '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$http_x_xsrf_token"';
access_log  /var/log/nginx/access_log  debug;

Upvotes: 9

Related Questions