nginxpermissionspagespeedmod-pagespeed

ngx_pagespeed not optimizing on AWS ubuntu 16.04 nginx/1.17.8


I've configured ngx_pagespeed as I usually do and it has worked everywhere else.

But on this particular AWS instance it does not seem to be optimizing anything.

I do get the expected response headers from nginx x-page-speed: 1.13.35.2-0, and I see pagespeed beacon watching elements on pages.

BUT - in the end nothing gets optimized. No CSS is combined or rewritten, no images get converted to webp or lazyloaded - NOTHING.

I've warmed up pages quite a bit, visiting a few dozen times from different browsers and devices. Usually at this point I'd see optimizations happening.

Can someone suggest what could be wrong? Could it be a permissions issue?

Just to be sure I ran sudo chown -R www-data:www-data /var/ngx_pagespeed_cache/ , but nothing changed.

Here's my nginx.conf for reference:

user www-data;
worker_processes auto;
pid /run/nginx.pid;


events {
       worker_connections 768;
}

http {
       ##
       # Basic Settings
       ##

       sendfile on;
       tcp_nopush on;
       tcp_nodelay on;
       keepalive_timeout 65;
       types_hash_max_size 2048;
       include /etc/nginx/mime.types;
       default_type application/octet-stream;

       pagespeed on;
       pagespeed FileCachePath /var/ngx_pagespeed_cache;
       pagespeed RewriteLevel PassThrough;
       pagespeed EnableFilters rewrite_css,combine_css,responsive_images,rewrite_images,lazyload_images,inline_preview_images,resize_images,resize_mobile_images,remove_comments,collapse_whitespace,extend_cache,insert_dns_prefetch,in_place_optimize_for_browser,remove_comments;

        pagespeed MinImageSizeLowResolutionBytes 10000;
        pagespeed InPlaceRewriteDeadlineMs 50;
        pagespeed PrivateNotVaryForIE off;
        pagespeed CriticalImagesBeaconEnabled false;

       ##
       # SSL Settings
       ##

       ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
       ssl_prefer_server_ciphers on;
       access_log /var/log/nginx/access.log;
       error_log /var/log/nginx/error.log;
       include /etc/nginx/conf.d/*.conf;
       include /etc/nginx/sites-enabled/*
}

Solution

  • Turns out I needed to add pagespeed Domain http*://mydomain.com;

    Not exactly sure why, since resources were served from the same domain and I never had to do this before, but may have to do with the fact that pagespeed only optimizes resources over HTTP, and there was a load balancer in front of this server.

    The http part in the line above is important. It wouldn't work with https in this case.