If you have mod_pagespeed installed on your webserver you may notice the following lines in access.log file:
1 2 3 |
*ipofserver* - - [24/Jan/2019:13:40:13 +0100] "GET /wp-content/***.jpg HTTP/1.1" 200 1806 "https://***.com/*" "Serf/1.3.9 (mod_pagespeed/1.13.35.2-0)" *ipofserver* - - [24/Jan/2019:13:40:13 +0100] "GET /wp-content/***.jpg HTTP/1.1" 200 1806 "https://***.com/*" "Serf/1.3.9 (mod_pagespeed/1.13.35.2-0)" *ipofserver* - - [24/Jan/2019:13:40:13 +0100] "GET /wp-content/***.jpg HTTP/1.1" 200 1806 "https://***.com/*" "Serf/1.3.9 (mod_pagespeed/1.13.35.2-0)" |
Depending on the size of your website requests from mod_pagespeed can add flood your logfiles and their size will be significantly larger. Here is how you can exclude mod_pagespeed requests from access.log file
Apache
To exclude mod_pagespeed requests from Apache access.log file use SetEnvIf directive (for more information and examples see the article How not to log certain requests in Apache).
You can filter mod_pagespeed requests by IP address or by User-Agent. In the global, vhost configuration or in .htaccess file define the following:
1 |
SetEnvIf User_Agent "Serf/1.3.9 (mod_pagespeed/1.13.35.2-0)" dontlog |
1 |
SetEnvIf Remote_Addr "192.168.0.154" dontlog |
where
192.168.0.154
is *ipofserver*
from the log above.
Now find the CustomLog directive in your Apache configuration, e.g.
1 |
CustomLog /var/log/apache2/access.log combined |
and add env=!dontlog
to the line:
1 |
CustomLog /var/log/apache2/access.log combined env=!dontlog |
Save the configuration file and restart Apache.
Nginx
For Nginx we use similar approach, filter by IP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
map $remote_addr $log_ip { "192.168.0.154" 0; default 1; } server { […] access_log /var/log/nginx/access.log main if=$log_ip; } |
where 192.168.0.154
is *ipofserver*
from the log above.
By User-Agent:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
map $http_user_agent $log_ua { ~Serf/1.3.9 (mod_pagespeed/1.13.35.2-0) 0; default 1; } server { […] access_log /var/log/nginx/access.log main if=$log_ua; } |
Save config files and restart Nginx.
Good luck!