在Nginx中logging自定义的proxy_set_header

我有一个问题在我的nginx上logging一个自定义的proxy_set_header。

我有nginx作为反向代理位于同一个服务器(用于testing)的apache服务器。 这个名为“xreqid”的头文件充当每个事务的唯一ID,并设置为各种variables,如$ pid $ msec。 这个头文件是使用proxy_set_header创build的,以便在后端服务器上传递。 而且,标题的内容首先被“设置”为随后用于标题“xreqid”的variables名“reqid”

nginx的前端configuration很简单:

server { listen 80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name _; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; set $reqid $pid-$msec-$remote_addr-$request_length; proxy_set_header xreqid $reqid; location / { proxy_pass http://localhost:8080/; try_files $uri $uri/ =404; } # Log formating access_log /var/log/nginx/unified.access.log my_log_format; 

和日志格式:

 log_format my_log_format '$hostname "$http_user_agent" --reqidInVar-- $reqid --reqidInHEADER---$http_xreqid' ; 

apache2后端服务器只是显示一个简单的静态html页面。

我的问题是,当我看着nginx日志variablesreqid打印,但没有标题。 但是,在后端日志(apache2)上打印这些信息没有问题。

换句话说,proxy_set_header $ xreqid可以在后台日志中看到,但不能在实际生成头文件的nginx日志中看到。 我也试图打印“经典”$ http_x_real_ip,但仍然在日志中为空。