Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx PageSpeed PageSpeed isn't compressing images even with tweaked conf.

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by cr0, Sep 10, 2017.

  1. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: latest
    • PHP Version Installed: latest
    • MariaDB MySQL Version Installed: latest
    • When was last time updated Centmin Mod code base ? : fresh install
    • Persistent Config: No
    Hello once again. Thank you a lot for the previous responses eva, much appreciated. The issue I'm facing now is: I want to use pagespeed to automatically compress the images, instead of a paid plugin, but it seems to not be working.

    I've been looking into EWWW Image Optimizer, but it seems like it's paid, isn't it? And Optimus can only optimize images <100kb. And instead of using all that nonsense to overload WordPress with more plugins I decided to use pagespeed. I think it's configured well, but the images aren't compressed, at least from what I can see in google page speed test.

    So far I've achieved 87/100 for mobile and 92/100 for desktop score at google:
    [​IMG]

    Using a premium theme that has 72/100 score on their hosting and had 54/100 when I installed it the first time.

    I'm using forced HTTPS on CloudFlare with a working certificate. CloudFlare has minifying and caching enabled, PLUS, there's Cache Enabler plugin + optimus installed. I think it's not needed when the server has mod_pagespeed?

    Another question:

    How to leverage browser caching? For example I got this message in google speed insights:

    [​IMG]

    Do I need to specify something for *.woff extension to leverage caching?

    Here's the config:

    PHP:
    pagespeed on;

    pagespeed LoadFromFileMatch "^https?://MYDOMAIN.com/" "/home/nginx/domains/MYDOMAIN.com/public/";
    pagespeed LoadFromFileRuleMatch disallow .*;
    pagespeed LoadFromFileRuleMatch allow \.css$;
    pagespeed LoadFromFileRuleMatch allow \.jpe?g$;
    pagespeed LoadFromFileRuleMatch allow \.png$;
    pagespeed LoadFromFileRuleMatch allow \.jpg$;
    pagespeed LoadFromFileRuleMatch allow \.gif$;
    pagespeed LoadFromFileRuleMatch allow \.js$;

    #######################################################
    # Purge nginx pagespeed cache
    # https://developers.google.com/speed/pagespeed/module/system#flush_cache
    #######################################################
    pagespeed EnableCachePurge on;
    pagespeed PurgeMethod PURGE;

    #######################################################
    # File cache settings
    ######################################
    # needs to exist and be writable by nginx

    # pagespeed FileCacheSizeKb          102400;
    # pagespeed FileCacheCleanIntervalMs 3600000;
    # pagespeed FileCacheInodeLimit      500000;

    #######################################################
    # By default, ngx_pagespeed adds an X-PageSpeed header with a value of the version of
    # ngx_pagespeed being used. This directive lets you specify the value to use instead:
    # pagespeed XHeaderValue "ngx_pagespeed";

    #######################################################
    # let's speed up PageSpeed by storing it in the super duper fast memcached
    # Ensure Memcached server installed http://centminmod.com/memcached.html
    # default install for centmin mod is on port 11211, so localhost:11211 is correct
    # uncomment - remove hash # in front of below 2 lines to enable
    # timeout set at 100 milliseconds
    #  pagespeed MemcachedThreads 1;
    #  pagespeed MemcachedServers "localhost:11211";
    #  pagespeed MemcachedTimeoutUs 100000;

    #######################################################
    ## 1.11.33.0 beta save-data
    ######################################
    # https://developers.google.com/speed/pagespeed/module/filter-image-optimize#image-quality

    # https://developers.google.com/speed/pagespeed/module/reference-image-optimize#JpegQualityForSaveData
    pagespeed JpegQualityForSaveData 50;

    # https://developers.google.com/speed/pagespeed/module/reference-image-optimize#WebpQualityForSaveData
    pagespeed WebpQualityForSaveData 50;

    #######################################################
    ## 1.7.30.1 beta defaults
    ######################################
    pagespeed PreserveUrlRelativity on;
    pagespeed MaxCombinedCssBytes -1;
    pagespeed ImageResolutionLimitBytes 16777216;
    # pagespeed EnableFilters inline_google_font_css;

    #######################################################
    ## 1.6.29.3 beta defaults
    ######################################
    pagespeed AvoidRenamingIntrospectiveJavascript on;
    pagespeed ImageInlineMaxBytes 3072;
    pagespeed CssImageInlineMaxBytes 0;
    pagespeed MaxInlinedPreviewImagesIndex -1;
    pagespeed MinImageSizeLowResolutionBytes 3072;

    #######################################################
    ## ngx_pagespeed filters settings below ##
    ######################################

      # show half the users an optimized site, half the regular site
      # change UA-XXXXXXXXXX-1 to your GA unique id
      # uncomment - remove hash # in front of below 5 lines to enable
    #  pagespeed RunExperiment on;
    #  pagespeed AnalyticsID UA-XXXXXXXXXX-1;
    #  pagespeed ExperimentVariable 1;
    #  pagespeed ExperimentSpec "id=1;percent=50;level=CoreFilters;enabled=collapse_whitespace,remove_comments;";
    #  pagespeed ExperimentSpec "id=2;percent=50";
     
      # Filter settings
      # filters outlined at http://ngxpagespeed.com/ngx_pagespeed_example/
      
    pagespeed RewriteLevel CoreFilters;
      
    pagespeed EnableFilters collapse_whitespace,remove_comments;

      
    # make_google_analytics_async
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-make-google-analytics-async
    #  pagespeed EnableFilters make_google_analytics_async;

      # make_show_ads_async
      # https://developers.google.com/speed/pagespeed/module/filter-make-show-ads-async
    #  pagespeed EnableFilters make_show_ads_async;

      # responsive_images, responsive_images_zoom
      # https://developers.google.com/speed/pagespeed/module/filter-image-responsive
    #  pagespeed EnableFilters responsive_images;
    #  pagespeed EnableFilters responsive_images_zoom;

      # convert_to_webp_animated
      # https://developers.google.com/speed/pagespeed/module/filter-image-optimize#convert_to_webp_animated
      
    pagespeed EnableFilters convert_to_webp_animated;

      
    # inline_google_font_css
      # https://developers.google.com/speed/pagespeed/module/filter-css-inline-google-fonts
      
    pagespeed EnableFilters inline_google_font_css;
      
    # require FetchHttps if using https site
       
    pagespeed FetchHttps enable;

      
    # inline_css
      # https://developers.google.com/speed/pagespeed/module/filter-css-inline
    #   pagespeed EnableFilters inline_css;
    #   pagespeed CssInlineMaxBytes 2048;

      # prioritize_critical_css
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-prioritize-critical-css
    #   pagespeed EnableFilters prioritize_critical_css;

      # move_css_to_head
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-css-to-head
      
    pagespeed EnableFilters move_css_to_head;

      
    # move_css_above_scripts
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-css-above-scripts
    #  pagespeed EnableFilters move_css_above_scripts;

      # combine_css
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-css-combine
    #  pagespeed EnableFilters combine_css;

       # Uncomment this if you want to prevent mod_pagespeed from combining files
       # (e.g. CSS files) across paths
       #
    #  pagespeed CombineAcrossPaths off;

      # combine_javascript
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-js-combine
    #  pagespeed EnableFilters combine_javascript;
    #  pagespeed MaxCombinedJsBytes 122900;

      # extend_cache
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-cache-extend
    pagespeed EnableFilters extend_cache;

      
    # rewrite_css
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-css-rewrite
    #  pagespeed EnableFilters rewrite_css;

      # rewrite_javascript
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-js-minify
    #  pagespeed EnableFilters rewrite_javascript;

      # inline_preview_images
      # https://developers.google.com/speed/pagespeed/module/filter-inline-preview-images
      
    pagespeed EnableFilters inline_preview_images;

      
    # lazyload_images
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-lazyload-images
    #  pagespeed EnableFilters lazyload_images;

      # rewrite_images
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-image-optimize
      
    pagespeed EnableFilters rewrite_images;
       
    pagespeed EnableFilters recompress_images;
       
    pagespeed DisableFilters convert_png_to_jpeg;
       
    pagespeed DisableFilters extend_cache_images;
    #  pagespeed EnableFilters convert_png_to_jpeg;
      
    pagespeed EnableFilters convert_jpeg_to_webp;
      
    pagespeed EnableFilters convert_to_webp_lossless;

      
    # sprite_images
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-image-sprite
    # pagespeed EnableFilters rewrite_css,sprite_images;

      # insert_dns_prefetch
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-insert-dns-prefetch
    #  pagespeed EnableFilters insert_dns_prefetch;

      # InPlaceResourceOptimization
      # https://developers.google.com/speed/pagespeed/module/system#ipro
      # Enabled by default as of 1.9.32.1
      
    pagespeed InPlaceResourceOptimization off;

    #######################################################
    Thank you once again!!
     
  2. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    free and paid options, so use free

    centmin mod defaults to 30 days expiry for fonts so something changed that to 24hrs, could be cloudflare settings related or something else ? you'd have to figure that out as it's nginx settings not pagespeed related

    pagespeed.conf looks good to me

    You'd have to troubleshoot and tweak it yourself following these guides and info outlined below
    But not much we can do without real domain/site to check out. Pagespeed also skips optimise images if there's no savings to me made in terms of image sizes.

    what isn't needed ? optimus or cache enabler ? cache enabler you can keep enabled.
     
  3. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    example from pagespeed troubleshooting threads, enabling pagespeed admin console accessed via yourhostname/pagespeed_global_admin/message_history can reveal logs for troubleshooting

    i.e. for my forums here accessing hostname/pagespeed_global_admin/graphs#image_rewriting shows stats for image rewrites (just restarted my nginx server so fresh stats)

    upload_2017-9-10_3-11-43.png
     
  4. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    I will try it ASAP, thanks!

    I used EWWW image optimizer to optimize all the images but there's still images to be optimized:

    [​IMG]

    --------------------------------

    To address the .woff extension error, here's what I got on http and https vhost nginx conf for header expires:

    PHP:
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 30d;
    add_header Cache-Control "public, no-transform";
    }

    location ~* \.(jpg|jpeg|gif|png)$ {
    expires 365d;
    }

    location ~* \.(pdf|css|html|js|swf)$ {
    expires 2d;
    }

    location ~* \.(woff)$ {
    expires 24h;
    add_header Cache-Control "public";
    }
    But Google still isn't picking it up:
    [​IMG]

    --------------------------------

    I thought having mod pagespeed + cloudflare minify + cache enable html & css minify enabled wouldn't work right. I'm not sure about that.

    --------------------------------

    Do you have any suggestions to address CSS blocking resources? I've been reading, but you're more knowledgeable.
     
  5. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    ADD:
    After looking at pagespeed admin page, there's nothing in Image Rewriting:

    [​IMG]


    Nothing shows up in console graphs:

    [​IMG]

    Also:

    I can't purge cache because the setting isn't "enabled", but when I look into pagespeed.conf it's all good.

    In pagespeed admin page:
    PHP:
    Purging not enabledplease add
      pagespeed EnableCachePurge on
    ;
    In pagespeed.conf:
    PHP:
    pagespeed EnableCachePurge on;
    pagespeed PurgeMethod PURGE;
     
    Last edited: Sep 10, 2017
  6. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    EWWW free is lossless optimisation only hence more room for improvement, and i believe cloudflare image optimisation is lossless too ? that's where optimise-images.sh script came in to do lossy optimisations https://community.centminmod.com/th...-optimizer-wordpress-plugin.12573/#post-53333

    that's 24hr expiry which is what Google is complaining about being too short

    centmin mod sets default to 30 days in /usr/local/nginx/conf/staticfiles.conf

    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)

    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)

    what is output of these commands in ssh
    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    

    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    wrap output in CODE tags
     
  7. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    if you temp disable cloudflare on specific image heavy page url via cloudflare page rules, does ngx_pagespeed work ?
     
  8. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    looks like indeed pagespeed might need these settings PageSpeed HTTPS Support

    For CentOS
    Code (Text):
      # https://www.modpagespeed.com/doc/https_support
       pagespeed SslCertDirectory /etc/pki/tls/certs;
       pagespeed SslCertFile /etc/pki/tls/cert.pem;
    

     
  9. noly

    noly Member

    53
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +18
    Local Time:
    6:18 AM
    1.13.3
    10
    Hi @cr0 , according to the docs you could disable direct https fetching:

    PageSpeed HTTPS Support

    Is ps working for you on a non-ssl domain?

    When creating a vhost via centmin menu option 2 your conf comes with some very handy include_files you have to comment out...i don't see that in your code though.
    You might have to tweak the filters according to your needs of course.

    Code:
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    See here too.. Configuring PageSpeed Filters

    You can then test your site by adding e.g. "?ModPagespeed=off" or "?ModPagespeed=on" to your domain..

    Code:
    http://www._domain_.com/?ModPagespeed=on
    But this shouldn't be necessary since your source code should be pagespeed optimized. But for quick testing you can also visit this site Is mod_pagespeed working?

    Hope you'll get pagespeed up&running smooth soon. :)
     
    • Informative Informative x 1
  10. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    does that only check mod_pagespeed as i tested centminmod.com and this forums and it reports pagespeed not working it in fact it is so not sure how much you can rely on that test site :) Probably because I hide or modify the pagespeed reported headers too heh
     
  11. noly

    noly Member

    53
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +18
    Local Time:
    6:18 AM
    1.13.3
    10
    Hmm...

    Code:
    Success! Mod_Pagespeed is running on that domain.
    Here are the headers we received:
    200: OK
    content-type: text/html; charset=UTF-8
    transfer-encoding: chunked
    connection: close
    vary: Accept-Encoding
    server: nginx centminmod
    x-powered-by: centminmod
    date: Sun, 10 Sep 2017 07:57:36 GMT
    x-page-speed: 1.12.34.2-0
    cache-control: max-age=0, no-cache
     
  12. noly

    noly Member

    53
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +18
    Local Time:
    6:18 AM
    1.13.3
    10
    I guess that's because of your headers. :)

    Edit: no it's not. Just changed mine accordingly to yours but the site still recognizes pagespeed on my domain. But you are right..it's definitely nothing to rely on.

    @cr0 :
    Forgot one other debugging tool though...by adding ?PageSpeedFilters=+debug to your domain and looking into your source code you can get a summarized computation status.
    Compare to the previous mentioned method.. ..your IP doesn't have to be whitelisted to get the status. (Sorry Georg..hope that's ok...)

    CentminMod.com LEMP Fully Optimized Nginx web stack for CentOS
     
    Last edited: Sep 10, 2017
    • Agree Agree x 1
  13. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    yes good tip :)
     
  14. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    I don't have image minify in cloudflare, only AMP enabled and HTML/CSS/JS.

    I would like to have pagespeed for images, but if it's not working, I will look into your solution!

    Strange, I don't think staticfiles.conf is loading because I'm still receiving the error to leverage browser caching on woocommerce .woff extension (24 hours). I checked cloudflare and found out I had some page rules, browser caching expiration set to 1 day, changed it to "Respect Existing Headers", besides I had Cache Expiry set to 24 hours in Cache Enabler and I set it to 0 (infinite) so let's see how it's going.

    EDIT:
    Yep, including staticfiles.conf isn't working, as I'm receiving the following now:
    [​IMG]
    There's an issue with include /usr/local/nginx/conf/pagespeedstatslog.conf; too, if it's not included in vhost conf's, console won't work.

    Below are the .conf's. I tweaked them how you said and also, according to pagespeed docs for the following errors in console:
    [​IMG]

    Also, adding SSL line to include certificates for pagespeed made it work in ismodpagespeedworking.com!

    -----------------

    MYDOMAIN.COM.conf
    PHP:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html

    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name MYDOMAIN.com;
    #            return 301 $scheme://www.MYDOMAIN.com$request_uri;
    #       }

    server {
     
      
    server_name MYDOMAIN.com www.MYDOMAIN.com;

    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    include /usr/local/nginx/conf/pagespeedstatslog.conf;

      
    #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;

      # limit_conn limit_per_ip 16;
      # ssi  on;

      
    access_log /home/nginx/domains/MYDOMAIN.com/log/access.log combined buffer=256k flush=5m;
      
    error_log /home/nginx/domains/MYDOMAIN.com/log/error.log;

      include /
    usr/local/nginx/conf/autoprotect/MYDOMAIN.com/autoprotect-MYDOMAIN.com.conf;
      
    root /home/nginx/domains/MYDOMAIN.com/public;
      
    # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      
    include /usr/local/nginx/conf/503include-main.conf;

      include /
    usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpcacheenabler_MYDOMAIN.com.conf;
      
    #include /usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpsupercache_MYDOMAIN.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/MYDOMAIN.com/rediscache_MYDOMAIN.com.conf;

      
    location / {
      include /
    usr/local/nginx/conf/503include-only.conf;
     
      
    location /webp {
      
    #pagespeed off;
      
    autoindex on;
      
    add_header X-Robots-Tag "noindex, nofollow";
      
    location ~* ^/webp/.+\.(png|jpe?g)$ {
        
    expires 30d;
        
    add_header Vary "Accept-Encoding";
        
    add_header Cache-Control "public, no-transform";
        
    try_files $uri$webp_extension $uri =404;
      }
    }
     

      
    # Enables directory listings when index file not found
      #autoindex  on;

      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;

      # for wp cache enabler plugin
      
    try_files $cache_enabler_uri $uri $uri$custom_subdir/index.php?$args;

      
    # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;

      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;

      
    }

    location ~* /(wp-login\.php) {
        
    limit_req zone=xwplogin burst=1 nodelay;
        
    #limit_conn xwpconlimit 30;
        
    auth_basic "Private";
        
    auth_basic_user_file /home/nginx/domains/MYDOMAIN.com/htpasswd_wplogin
        include /
    usr/local/nginx/conf/php-wpsc.conf;
        
    # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }

    location ~* /(xmlrpc\.php) {
        
    limit_req zone=xwprpc burst=45 nodelay;
        
    #limit_conn xwpconlimit 30;
        
    include /usr/local/nginx/conf/php-wpsc.conf;
        
    # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }

      include /
    usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpsecure_MYDOMAIN.com.conf;
      include /
    usr/local/nginx/conf/php-wpsc.conf;
     
      
    # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      
    include /usr/local/nginx/conf/pre-staticfiles-local-MYDOMAIN.com.conf;
      include /
    usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /
    usr/local/nginx/conf/staticfiles.conf;
      include /
    usr/local/nginx/conf/drop.conf;
      
    #include /usr/local/nginx/conf/errorpage.conf;
      
    include /usr/local/nginx/conf/vts_server.conf;
    }
    MYDOMAIN.COM.ssl.conf
    PHP:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    # For SPDY SSL Setup
    # read http://centminmod.com/nginx_configure_https_ssl_spdy.html

    # redirect from www to non-www  forced SSL
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    # server {
    #   server_name MYDOMAIN.com www.MYDOMAIN.com;
    #    return 302 https://$server_name$request_uri;
    # }

    server {
      
    listen 443 ssl http2;
      
    server_name MYDOMAIN.com www.MYDOMAIN.com;

      
    ssl_dhparam /usr/local/nginx/conf/ssl/MYDOMAIN.com/dhparam.pem;
      
    ssl_certificate      /usr/local/nginx/conf/ssl/MYDOMAIN.com/public.pem;
      
    ssl_certificate_key  /usr/local/nginx/conf/ssl/MYDOMAIN.com/private.key;
      include /
    usr/local/nginx/conf/ssl_include.conf;
      
    http2_max_field_size 16k;
      
    http2_max_header_size 32k;
      
    # mozilla recommended
      
    ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
      
    ssl_prefer_server_ciphers   on;
      
    #add_header Alternate-Protocol  443:npn-spdy/3;

      # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts
      #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #spdy_headers_comp 5;
      
    ssl_buffer_size 1369;
      
    ssl_session_tickets on;
     
      
    # enable ocsp stapling
      #resolver 8.8.8.8 8.8.4.4 valid=10m;
      #resolver_timeout 10s;
      #ssl_stapling on;
      #ssl_stapling_verify on;
      #ssl_trusted_certificate /usr/local/nginx/conf/ssl/MYDOMAIN.com/MYDOMAIN.com-trusted.crt;

    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    include /usr/local/nginx/conf/pagespeedstatslog.conf;

      
    #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;

      # limit_conn limit_per_ip 16;
      # ssi  on;

      
    access_log /home/nginx/domains/MYDOMAIN.com/log/access.log combined buffer=256k flush=5m;
      
    error_log /home/nginx/domains/MYDOMAIN.com/log/error.log;

      include /
    usr/local/nginx/conf/autoprotect/MYDOMAIN.com/autoprotect-MYDOMAIN.com.conf;
      
    root /home/nginx/domains/MYDOMAIN.com/public;
      
    # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      
    include /usr/local/nginx/conf/503include-main.conf;

      include /
    usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpcacheenabler_MYDOMAIN.com.conf;
      
    #include /usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpsupercache_MYDOMAIN.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/MYDOMAIN.com/rediscache_MYDOMAIN.com.conf;

      
    location / {
      include /
    usr/local/nginx/conf/503include-only.conf;
     

      
    # Enables directory listings when index file not found
      #autoindex  on;

      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;

      # for wp cache enabler plugin
      
    try_files $cache_enabler_uri $uri $uri$custom_subdir/index.php?$args;

      
    # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;

      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;

      
    }

    location ~* /(wp-login\.php) {
        
    limit_req zone=xwplogin burst=1 nodelay;
        
    #limit_conn xwpconlimit 30;
        
    auth_basic "Private";
        
    auth_basic_user_file /home/nginx/domains/MYDOMAIN.com/htpasswd_wplogin
        include /
    usr/local/nginx/conf/php-wpsc.conf;
     
        
    # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }

        
    # prepare for letsencrypt
        # https://community.centminmod.com/posts/17774/
        
    location ~ /.well-known location ~ /.well-known/acme-challenge/(.*) { more_set_headers    "Content-Type: text/plain"; } }

    location ~* /(xmlrpc\.php) {
        
    limit_req zone=xwprpc burst=45 nodelay;
        
    #limit_conn xwpconlimit 30;
        
    include /usr/local/nginx/conf/php-wpsc.conf;
     
        
    # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }

      include /
    usr/local/nginx/conf/wpincludes/MYDOMAIN.com/wpsecure_MYDOMAIN.com.conf;
      include /
    usr/local/nginx/conf/php-wpsc.conf;
     
      
    # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      
    include /usr/local/nginx/conf/pre-staticfiles-local-MYDOMAIN.com.conf;
      include /
    usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /
    usr/local/nginx/conf/staticfiles.conf;
      include /
    usr/local/nginx/conf/drop.conf;
      
    #include /usr/local/nginx/conf/errorpage.conf;
      
    include /usr/local/nginx/conf/vts_server.conf;
    }


    Code (Text):
    curl -I https://MYDOMAIN.COM
    -----
    curl: (60) Peer's Certificate issuer is not recognized.
    More details here: http://curl.haxx.se/docs/sslcerts.html
    
    curl performs SSL certificate verification by default, using a "bundle"
     of Certificate Authority (CA) public keys (CA certs). If the default
     bundle file isn't adequate, you can specify an alternate file
     using the --cacert option.
    If this HTTPS server uses a certificate signed by a CA represented in
     the bundle, the certificate verification probably failed due to a
     problem with the certificate (it might be expired, or the name might
     not match the domain name in the URL).
    If you'd like to turn off curl's verification of the certificate, use
     the -k (or --insecure) option.
    


    Code (Text):
    curl -I https://www.MYDOMAIN.COM
    -----
    
    HTTP/1.1 301 Moved Permanently
    Date: Sun, 10 Sep 2017 18:41:26 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Set-Cookie: __cfduid=df7f1bef903745e7c25d0e06da996360c1505068886; expires=Mon, 10-Sep-18 18:41:26 GMT; path=/; domain=.MYDOMAIN.com; HttpOnly
    Location: https://MYDOMAIN.COM/
    X-Powered-By: centminmod
    X-Page-Speed: 1.12.34.2-0
    Cache-Control: max-age=0, no-cache
    Server: cloudflare-nginx
    CF-RAY: 39c4857e0e3b64ab-FRA
    
    


    Code (Text):
    curl -I http://domain.com
    ---------
    HTTP/1.1 200 OK
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    Server: nginx centminmod
    X-Powered-By: centminmod
    Date: Sun, 10 Sep 2017 18:40:16 GMT
    X-Page-Speed: 1.12.34.2-0
    Cache-Control: max-age=0, no-cache
    
    


    Code (Text):
    curl -I http://www.MYDOMAIN.COM
    ------
    HTTP/1.1 301 Moved Permanently
    Date: Sun, 10 Sep 2017 18:42:44 GMT
    Connection: keep-alive
    Cache-Control: max-age=3600
    Expires: Sun, 10 Sep 2017 19:42:44 GMT
    Location: https://www.MYDOMAIN.COM
    Server: cloudflare-nginx
    CF-RAY: 39c48767336226b4-FRA
    



    Yes! PageSpeed is working on https now!

    Thank you for joining us! Just disabled https fetching, no changes, I think. Yep, it's working since including SSL cert's in pagespeed conf.

    The only thing I uncommented was include /usr/local/nginx/conf/pagespeedstatslog.conf;

    Because otherwise, console wouldn't work, I don't know why.

    Not sure how to use it. Nothing shows up when using curl -D or curl -I in ssh, and in browser I receive the error "too many redirects".

    Thanks!
     
    Last edited: Sep 11, 2017
  15. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    did you read instructions at Nginx PageSpeed - CentminMod.com LEMP Nginx web stack for CentOS ?
     
  16. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    Also, I set this in php.ini:

    PHP:
    Set to {nocache,private,public,} to determine HTTP caching aspects
    ; or leave this empty to avoid sending anti-caching headers.
    http://php.net/session.cache-limiter
    session.cache_limiter = public
    Yes, I did, and also you said in other thread that it's not needed, as pagespeed is working on all vhosts if it's left unchanged.

    EDIT:
    This message appears when # is uncommented on all 3 of them.

    PHP:
    Reloading nginx configuration (via systemctl):  Job for nginx.service failed because the control process exited with error codeSee "systemctl status nginx.service" and "journalctl -xe" for details.
                                                               [
    FAILED]
     
  17. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    must of misread what i said

    as to error what does command to check nginx conf say
    Code (Text):
    nginx -t
    
     
  18. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    :)
     
  19. cr0

    cr0 Member

    37
    2
    8
    Aug 21, 2017
    Ratings:
    +2
    Local Time:
    6:18 AM
    Must be! Thank you.

    PHP:
    nginx: [warn] [ngx_pagespeed 1.12.34.2-0] [0910/192551:WARNING:google_message_handler.cc(56)] 'MessageBufferSize' is global and is ignored at this scope
    nginx
    : [emergunknown directive "mypublic ip" in /usr/local/nginx/conf/pagespeedhandler.conf:6
    nginx
    configuration file /usr/local/nginx/conf/nginx.conf test failed
    I had this in pagespeedhandler:

    Code:
    { allow 127.0.0.1; mypublicip; deny all; }
    But now I can't get into pagespeed admin page - 403 forbidden error.
     
  20. eva2000

    eva2000 Administrator Staff Member

    29,720
    6,711
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,015
    Local Time:
    2:18 PM
    Nginx 1.13.x
    MariaDB 5.5
    missing allow before mypublicip

    as to MessageBufferSize it's set in /usr/local/nginx/conf/pagespeedadmin.conf nowadays

    command shortcut to use nano to edit /usr/local/nginx/conf/pagespeedadmin.conf
    Code (Text):
    pscontrol admin
    


    from Nginx PageSpeed - CentminMod.com LEMP Nginx web stack for CentOS