Want more timely Centmin Mod News Updates?
Become a Member

Nginx PageSpeed Nginx Pagespeed Troubleshooting issues and errors

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by BamaStangGuy, May 25, 2014.

Tags:
  1. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    Thanks for the links. Trying to troubleshoot why no combines are happening for my xenForo forums. I notice it is working on here.

     
  2. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Brent, you can find this forum's pagespeed.conf posted at http://community.centminmod.com/threads/nginx-pagespeed-ngx_pagespeed-module.30/#post-38 for comparison as I have it tweaked for Xenforo usage. By default Xenforo's css.php based concatenation of CSS will not allow Pagespeed to combine them - hence why my pagespeed.conf excludes css.php. You would need to break apart css.php to be served as file based css.

    The only way I have found so far in my short search is via bdcache addon which allows you to save css files as files. Enable that first :)
     
  3. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    Hmmm updated to your conf and it still doesn't seem to be doing things it should here: https://www.aspiescentral.com/

    Javascript is still shown at the top and no js is combined
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Pagespeed needs a few page reloads that serve up a beacon request to properly analyse what it can optimise before it does its thing also remember to restart Nginx after making pagespeed.conf changes.
     
  5. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    Installed the BD Cache plugin and still not seeing CSS being combined. Its been running for a good 30+ minutes now
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Anything showing up in your message log from yourhostname.com/ngx_pagespeed_message ?
     
  7. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:28 PM
    Mainline
    10.2
    By the way, If you BD Cache addon installed and css are now serve as files then you have pagespeed combine css enabled.
    You will notice some broken pages sometimes.

    I have it enable sometime in my live forum, and it's causing some issue, so I disallow bdcache css to combine.
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah Matt reported some in this thread http://community.centminmod.com/threads/responsive-style.16/. I have included my forum's pagespeed.conf http://community.centminmod.com/threads/nginx-pagespeed-ngx_pagespeed-module.30/#post-38 which has excluded via pagespeed Disallow some Xenforo requests to fix the broken css to allow bdcache to css combine :)
     
  9. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    I'm having a hell of a time with pagecache, just trying to disable it.

    I did an upgrade on a server and got quite a few errors. Should
    include /usr/local/nginx/conf/pagespeedadmin.conf; not be commented out if pagecache is installed disabled? I get errors such as:

    nginx: [emerg] "gzip_types" directive FileCachePath must be set in

    nginx: [emerg] unknown directive "pagespeed" in

    On two servers I have had to compile nginx with pagespeed just to disable. If I do not compile with pagespeed then no matter how much I comment out related to pagespeed it throws errors when trying to start nginx.

    Anyway we can move to have pagespeed disabled by default? It seems like its a lot easier to enable it than it is to track everything down to properly disable it. At least that has been my experience with it in the last day.
     
  10. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Well at least 52% of users have ngx_pagespeed enabled/used http://community.centminmod.com/threads/centmin-mod-survey-2013-2014.82/.

    What does your /usr/local/nginx/conf/nginx.conf and /usr/locaal/nginx/conf/pagespeed.conf contents look like now ? Are you running on centmin.sh .06 stable or .07 beta version ? You'd probably need to run from .07 beta version if at any time in past you did run .07 beta on the servers as they make some changes to Nginx configuration.
     
  11. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    nginx.conf:

    Code:
    user              nginx nginx;
    worker_processes 2;
    worker_priority -10;
    
    worker_rlimit_nofile 51200;
    timer_resolution 100ms;
    
    error_log         logs/error.log;
    
    pid               logs/nginx.pid;
    
    events {
        worker_connections  1024;
        use epoll;
        #multi_accept on;
    }
    
    http {
    #include /usr/local/nginx/conf/pagespeedadmin.conf;
    
    include /usr/local/nginx/conf/fastcgi_param_https_map.conf;
    
    log_format      main    '$remote_addr - $remote_user [$time_local] $request '
                    '"$status" $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
                    ' "$connection" "$connection_requests" "$request_time"';
    
    access_log logs/access.log combined buffer=32k;
    
        index  index.php index.html index.htm;
        include       mime.types;
        default_type  application/octet-stream;
        charset utf-8;
    
            sendfile on;
            #sendfile_max_chunk 1m;
            tcp_nopush  on;
            tcp_nodelay off;
            server_tokens off;
            server_name_in_redirect off;
           
            keepalive_timeout  10;
            keepalive_disable msie6;
    
        gzip on;
        gzip_vary   on;
        gzip_disable "MSIE [1-6]\.";
            gzip_static on;
            gzip_min_length   1400;
            gzip_buffers      32 8k;
            gzip_http_version 1.0;
            gzip_comp_level 5;
            gzip_proxied    any;
            gzip_types text/plain text/css text/xml application/javascript  application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
    
    client_body_buffer_size 256k;
    client_body_in_file_only off;
    client_body_timeout 60s;
    client_header_buffer_size 64k;
    ## how long a connection has to complete sending
    ## it's headers for request to be processed
    client_header_timeout  20s;
    client_max_body_size 24M;
    connection_pool_size  512;
    directio  4m;
    ignore_invalid_headers on;      
    large_client_header_buffers 8 64k;
    output_buffers   8 256k;
    postpone_output  1460;
    proxy_temp_path  /tmp/nginx_proxy/;
    request_pool_size  32k;
    reset_timedout_connection on;
    send_timeout     180s;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
    
    # for nginx proxy backends to prevent redirects to backend port
    # port_in_redirect off;
    
    open_file_cache max=5000 inactive=30s;
    open_file_cache_valid 120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    open_log_file_cache max=1024 inactive=30s min_uses=2;
    
    ## limit number of concurrency connections per ip to 16
    ## add to your server {} section the next line
    ## limit_conn limit_per_ip 16;
    ## uncomment below line allows 500K sessions
    # limit_conn_log_level error;
    #######################################
    # use limit_zone for Nginx <v1.1.7 and lower
    # limit_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    # use limit_conn_zone for Nginx >v1.1.8 and higher
    # limit_conn_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    
    include /usr/local/nginx/conf/conf.d/*.conf;
    }
    
    pagespeed.conf:

    Code:
    pagespeed off;
    
    #######################################################
    # File cache settings 
    ######################################
    # needs to exist and be writable by nginx
    
    # pagespeed FileCacheSizeKb          102400;
    # pagespeed FileCacheCleanIntervalMs 3600000;
    # pagespeed FileCacheInodeLimit      500000;
    
    #######################################################
    # Set it to 0 if you want to disable this feature.
    # pagespeed MessageBufferSize 100000;
    
    #######################################################
    # 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;
    
    #######################################################
    ## https://developers.google.com/speed/pagespeed/module/admin#virtual-hosts-and-stats
    ######################################
    # pagespeed UsePerVhostStatistics on;
    
    #######################################################
    ## 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;
    
      # 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 DisableFilters rewrite_images;
       pagespeed DisableFilters 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;
    
      # Bound the number of images that can be rewritten at any one time; this
      # avoids overloading the CPU.  Set this to 0 to remove the bound.
      #
    #  pagespeed ImageMaxRewritesAtOnce 2;
    
      # insert_dns_prefetch
      # https://developers.google.com/speed/docs/mod_pagespeed/filter-insert-dns-prefetch
    #  pagespeed EnableFilters insert_dns_prefetch;
    
    #######################################################
    
    This is the server that, if I do not compile with pagespeed, it refuses to start nginx.
     
  12. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    All of these are on the .07 latest beta (21)
     
  13. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are you recompiling Nginx with .06 stable or .07 beta's centmin.sh ? Try ith .07 beta's zip directory and centmin.sh.

    .07 beta 21 is basically May 27 and 28 listed change commits at https://github.com/centminmod/centminmod/commits/123.07beta21.

    Majority of pagespeed changes came on May 10th due to ngx_pagespeed 1.8.31.2 beta changes
     
  14. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
  15. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    So let me get this right

    1. If you compile Nginx with default ngx_pagespeed added and have include /usr/local/nginx/conf/pagespeedadmin.conf; in nginx.conf, restart nginx gives errors ?
    2. If you comment out include /usr/local/nginx/conf/pagespeedadmin.conf; the in nginx.conf, restart nginx gives errors ?

    what's contents of /usr/local/nginx/conf/pagespeedadmin.conf ?

    you should have

    Code:
    #######################################################
    # 1.8.31.2 beta required paths
    # https://developers.google.com/speed/pagespeed/module/admin
    ######################################
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
    pagespeed MessagesPath /ngx_pagespeed_message;
    pagespeed ConsolePath /pagespeed_console;
    pagespeed AdminPath /pagespeed_admin;
    pagespeed GlobalAdminPath /pagespeed_global_admin;
    could be you're missing

    Code:
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    
    as that was added later in one of the .07 beta updates https://github.com/centminmod/centminmod/commit/da5f0b10a06578b423b2adf65e0a4c4f4861d902
     
  16. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    Steps to reproduce error:

    Disable pagespeed in centmin.sh
    Recompile nginx 1.7.1 with pagespeed disabled
    pagespeedadmin.conf is not commented out
    all pagespeed related conf files in vhost are commented out

    Error:

    Code:
    [root@s1 centminmod-123.07beta21]# nprestart 
    
    nginx: [emerg] unknown directive "pagespeed" in /usr/local/nginx/conf/pagespeedadmin.conf:5
    
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    
    Gracefully shutting down php-fpm . done
    
    Starting php-fpm  done
    
    [root@s1 centminmod-123.07beta21]# 
    pagespeedadmin.conf:

    Code:
    #######################################################
    
    # 1.8.31.2 beta required paths
    
    # https://developers.google.com/speed/pagespeed/module/admin
    
    ######################################
    
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    
    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    
    pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
    
    pagespeed MessagesPath /ngx_pagespeed_message;
    
    pagespeed ConsolePath /pagespeed_console;
    
    pagespeed AdminPath /pagespeed_admin;
    
    pagespeed GlobalAdminPath /pagespeed_global_admin;
     
  17. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah it doesn't like line 5

    Code:
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    if you comment out just that line 5 does it work ?

    or move that line back into /usr/local/nginx/conf/pagespeed.conf
     
  18. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    Code:
    [root@aspies ~]# nprestart 
    
    nginx: [emerg] unknown directive "pagespeed" in /usr/local/nginx/conf/pagespeedadmin.conf:6
    
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    
    Gracefully shutting down php-fpm . done
    
    Starting php-fpm  done
    No. I can reproduce this on all my sites on different servers.
     
  19. eva2000

    eva2000 Administrator Staff Member

    53,248
    12,117
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,655
    Local Time:
    12:28 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    is that with nginx pagespeed compiled into Nginx ? or only if it is not compiled ?
     
  20. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    9:28 AM
    When it is not compiled. pagespeedadmin.conf is never commented out when you do not compile it with pagespeed and it throws the errors.