I have set up an access log in PHP-FPM under pool.d/www.conf, and I noticed that the log usually constructs the URL as "index.php" with all query parameters, EXCEPT for 'q,' which is the URL. I know that this is removed by the server for clean URLs, so would anyone know how to collect this?

Looking at the access log format instructions, it seems like there should be a header specifying location. I'll see if I can find one in Charles Web Proxy.

Here are the relevant config file sections:

from NGINX site config:

location / {
    # try_files $uri @rewrite; # For Drupal <= 6
    try_files $uri /index.php?$query_string; # For Drupal >= 7

location @rewrite {
    rewrite ^/(.*)$ /index.php?q=$1;


location ~ '\.php$|^/update.php' {
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    # Security note: If you're running a version of PHP older than t$
    # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
    # See http://serverfault.com/q/627903/94922 for details.
    include fastcgi_params;
    # Block httpoxy attacks. See https://httpoxy.org/.
    fastcgi_param HTTP_PROXY "";
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_intercept_errors on;
    # PHP 5 socket location.
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    # PHP 7 socket location.
    #fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

from /path-to-php5/fpm/pool.d/www.conf

; The access log file
; Default: not set
access.log = /var/log/php5-fpm/$pool.access.log

; The access log format.
; The following syntax is allowed
;  %%: the '%' character
;  %C: %CPU used by the request


;  %e: an environment variable (same as $_ENV or $_SERVER)
;      it must be associated with embraces to specify the name of the env
;      variable. Some exemples:
;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e


;  %o: output header
;      it must be associated with embraces to specify the name of the header:
;      - %{Content-Type}o
;      - %{X-Powered-By}o
;      - %{Transfert-Encoding}o

;  %u: remote user
; Default: "%R - %u %t \"%m %r\" %s"
access.format = "%R|%u|%t|%m|%r%Q%q|%s|%f|%{mili}d|%{kilo}M|%C%%"

I am using

access.format = "[%t] %m %{REQUEST_SCHEME}e://%{HTTP_HOST}e%{REQUEST_URI}e %f pid:%p took:%ds mem:%{mega}Mmb cpu:%C%% status:%s {%{REMOTE_ADDR}e|%{HTTP_USER_AGENT}e}"

which logs lines like

[16/Nov/2018:23:54:13 +0100] GET https://realdomain.com/path?param /linux/path/file.php pid:1234 took:1.035s mem:2mb cpu:0.99% status:200 {|Mozilla/5.0 (full User-Agent)}

More info: https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in#L257-L318

  • 1
    Thank you! This saved me! – Drmzindec May 11 '20 at 20:06

Here's the answer I've come up with so far: I am having Drupal generate an X-URI header, and am adding %{X-URI}o to the log format. So far this is producing the type of report we are looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.