Web page archived as of 2018-05-22. Some links & features might not work.

Missing user in access.log with PHP-FPM

Since we switched to PHP5-FPM and FastCGI all protected PHP scripts showed an empty "Remote user" (Apache logged a dash) even though Apache did a basic authentication.

Installations of Apache often come with default LogFormat settings such as

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

where %u stands for "Remote user" according to the Custom Log Formats.

In order to fix the logging of usernames replace %u with %<u. The < is a modifier:

%<u can be used to record the original authenticated user on a request that is internally redirected to an unauthenticated resource

— quoted from mod_log_config - Apache HTTP Server (2013-10-18)
 
blog/131018_php-fpm_no_user_in_access_log.txt · Last modified: 2013-10-19 15:15 by andreas