I'm trying to pass headers from php code back to the apache accesslog by using HTTP headers, like so:
Header note X-Userid userid
Header unset X-Userid
LogFormat "%h %l %{userid}n %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_with_php_userid
CustomLog /var/log/apache2/access_log combined_with_php_userid
With mod_php
, the userid is inserted into the log as expected, and the header is unset before being sent to the client.
When running via php-fpm, using the following line, the userid is not inserted in the log and is not unset in the client HTTP headers.
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/var/html/$1
Originally I was using apache_note
but this is only available with mod_php
. I found the above as a solution for passing data from PHP to Apache/php-fpm or nginx, but it doesn't seem to work with php-fpm.
Is there something I need to enable or set to get Header unset
working under php-fpm?
Virtual Host Config:
<VirtualHost *:80>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/web/ee2/sites/site.com/$1
ServerAdmin [email protected]
DocumentRoot /web/ee2/sites/site.com
ServerName site.dev
Header note X-Userid userid
Header unset X-Userid
ErrorLog /var/log/apache2/site.dev-error_log
LogFormat "%h %l %{userid}n %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_with_php_userid
# also tried: # LogFormat "%h %l %{X-Userid}i %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_with_php_userid
CustomLog /var/log/apache2/searchenginenews.com-access_log combined_with_php_userid
<Directory /web/ee2/sites/site.com>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>