2 years ago

#304002

test-img

user17754583

How can I log a fastcgi_param value on the NGINX access log?

I was hoping to log a fastcgi_param on my NGINX access logs, similar to this:

fastcgi_param LOG_PARAM "testing";
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for" "$LOG_PARAM";

I've tried directly assigning this to the log format by the param's name, but it seems to result as a blank value. Later I've tried passing this param into an NGINX variable but no luck in that as well. There seemed to be no direct approach in doing this, I've tried to make use of the lua module, however, it's limited in its FastCGI support. https://github.com/openresty/lua-nginx-module/#ngxvarvariable

If there's any possible solution to make this happen, it would be very much appreciated.

php

ubuntu

nginx

server

fastcgi

0 Answers

Your Answer

Accepted video resources