google pageseed还是用不了gzip【解决:升级面板】

二月鸟 2020-3-30 595

文件都150k了还是没法gzip压缩
也在源文中加入了如下代码也没用
pagespeed FetchWithGzip on;
gzip on;
gzip_comp_level 6;
gzip_min_length 1k;
gzip_types text/plain text/css text/xml text/javascript text/x-component application/json application/javascript application/x-javascript application/xml application/xhtml+xml application/rss+xml application/atom+xml application/x-font-ttf application/vnd.ms-fontobject image/svg+xml image/x-icon font/opentype;
brotli on;
brotli_comp_level 6;
brotli_min_length 1k;
brotli_types text/plain text/css text/xml text/javascript text/x-component application/json application/javascript application/x-javascript application/xml application/xhtml+xml application/rss+xml application/atom+xml application/x-font-ttf application/vnd.ms-fontobject image/svg+xml image/x-icon font/opentype;
client_max_body_size 10M;

最新回复 (10)
  • 二月鸟 2020-3-30
    引用 2

    这是pageseed的nginx源文

    lua_shared_dict  appnode_sitemgr_cc_count_{website} 1m;
    lua_shared_dict  appnode_sitemgr_cc_blocked_{website} 100k;
    lua_shared_dict  appnode_sitemgr_cc_banned_{website} 100k;
    
    server {
        listen                     80;
        listen                     443 ssl http2;
        server_name                {website};
        server_name                {website};
        server_name                {website2};
        charset                    utf-8;
        ssl_certificate            /data/{cate}/sites/{website}/ssl/site.crt;
        ssl_certificate_key        /data/{cate}/sites/{website}/ssl/site.key;
        ssl_prefer_server_ciphers  on;
        ssl_ciphers                ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
        ssl_session_cache          shared:SSL:5m;
        ssl_session_timeout        5m;
        keepalive_timeout          75s;
        keepalive_requests         100;
        access_log                 /data/{cate}/sites/{website}/log/nginx/access.log;
        error_log                  /data/{cate}/sites/{website}/log/nginx/error.log;
        pagespeed                  on;
        pagespeed                  FileCachePath /data/{cate}/sites/{website}/cache/ngx_pagespeed;
        pagespeed                  LowercaseHtmlNames off;
        pagespeed                  PreserveUrlRelativity on;
        pagespeed                  RespectVary on;
        pagespeed                  XHeaderValue 'Powered By AppNode';
        pagespeed                  EnableFilters remove_comments,collapse_whitespace,combine_css,rewrite_css,rewrite_images,prioritize_critical_css,extend_cache;
        pagespeed                  FileCacheCleanIntervalMs 86400;
        pagespeed                  FileCacheSizeKb 102400;
        pagespeed                  FileCacheInodeLimit 500000;
        pagespeed                  AdminPath /pagespeed_admin;
        pagespeed                  PurgeMethod PURGE;
        pagespeed                  EnableCachePurge on;
        root                       /data/{cate}/sites/{website}/www;
    
        if ($scheme = http) {
            return  301 https://$host$request_uri;
        }
    
        if ($host = '{website}') {
            rewrite  ^/ http://{website}$request_uri permanent;
        }
    
        client_max_body_size       10M;
        access_by_lua_file         /data/{cate}/sites/{website}/conf/access.lua;
    
        location / {
            index    index.html index.htm index.php;
        
            if (-f $request_filename/index.html) {
                rewrite  (.*) $1/index.html break;
            }
        
            if (-f $request_filename/index.php) {
                rewrite  (.*) $1/index.php;
            }
        
            if (!-f $request_filename) {
                rewrite  (.*) /index.php;
            }
        
            rewrite  /wp-admin$ $scheme://$host$uri/ permanent;
            rewrite  ^/sitemap.xml$ /DiyCode/sIteMap/sitemap.php last;
            rewrite  ^.html/mip$ .html/mip/ last;
            rewrite  ^.html/amp$ .html/amp/ last;
            rewrite  ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ /index.php?xml_sitemap=params=$2 last;
            rewrite  ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ '/index.php?xml_sitemap=params=$2;zip=true' last;
            rewrite  ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ '/index.php?xml_sitemap=params=$2;html=true' last;
            rewrite  ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ '/index.php?xml_sitemap=params=$2;html=true;zip=true' last;
        }
    
        location = /__appnode_anti_cc_admin {
            allow  127.0.0.1;
            deny   all;
        }
    
        location = /__appnode_anti_cc_log {
            internal;
            access_log  /data/{cate}/sites/{website}/log/nginx/cc_attack.log;
        }
    
        location ~ '\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+' {
            add_header  '' '';
        }
    
        location ~ ^/pagespeed_static/ {
        }
    
        location ~ ^/pagespeed_admin {
            allow  127.0.0.1;
            deny   all;
        }
    
        location ~ ^/.+\.php(/|$) {
            include                  conf.sitemgr.d/global/conf/fastcgi_params;
            fastcgi_index            index.php;
            fastcgi_param            SCRIPT_FILENAME /data/{cate}/sites/{website}/www$fastcgi_script_name;
            fastcgi_split_path_info  ^(.+\.php)(/.*)$;
            fastcgi_param            PATH_INFO $fastcgi_path_info;
            fastcgi_param            PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_read_timeout     60s;
            fastcgi_pass             unix:/data/{cate}/php-pools/appnode_sitemgr_shared_OQpADt/php-fpm.sock;
        }
    
        location = /cms-onfig.php {
            deny  all;
        }
        
        location ~* /wp-includes/.*.php$ {
            deny  all;
        }
        
        location ~* /(?:uploads|files)/.*.php$ {
            deny  all;
        }
        
        location ~* \.(rar|zip|gz|tar|tgz|tar.gz|7z|z|bz2|tar.bz2|sql|log|ini|bak|old|conf|idea|DS_Store|swp|svn/entries|git/config)$ {
            deny  all;
        }
    }
    
  • 虚竹 2020-3-31
    引用 3

    配置看起来正常,和你相同的配置,F12中请求响应内容为:

    cache-control: max-age=0, no-cache, no-store
    content-encoding: gzip
    content-type: text/html; charset=utf-8
    date: Tue, 31 Mar 2020 01:44:03 GMT
    pragma: no-cache
    server: nginx
    status: 200
    vary: Accept-Encoding
    x-page-speed: Powered By AppNode


    content-encoding: gzip说明有gzip压缩。

    你是看F12的还是用第三方工具检测的?

  • 二月鸟 2020-3-31
    引用 4
    cache-control: max-age=0, no-cache
    content-type: text/html; charset=UTF-8
    date: Tue, 31 Mar 2020 08:51:19 GMT
    server: nginx/1.16.1
    status: 200
    x-page-speed: Powered By AppNode

    我只有这些
  • 二月鸟 2020-3-31
    引用 5
    F12看的
  • 二月鸟 2020-3-31
    引用 6
    包括第三方工具检测的 都没有
  • 虚竹 2020-3-31
    引用 7
    你用的是Nginx稳定版,测试了下确实不行,切换到Nginx开发版,就可以了。
  • 二月鸟 2020-4-1
    引用 8
    虚竹 你用的是Nginx稳定版,测试了下确实不行,切换到Nginx开发版,就可以了。
    切换到开发版了还是不行啊
  • 虚竹 2020-4-1
    引用 9
    二月鸟 切换到开发版了还是不行啊
    调试后发现是新版本pagespeed已经支持和gzip并存,网站管理应用升级到1.8.4以上版本,问题可以解决。
  • 二月鸟 2020-4-2
    引用 10
    虚竹 调试后发现是新版本pagespeed已经支持和gzip并存,网站管理应用升级到1.8.4以上版本,问题可以解决。
    那nginx是用1.16稳定版本还是继续用1.17开发版?
  • 虚竹 2020-4-2
    引用 11
    二月鸟 那nginx是用1.16稳定版本还是继续用1.17开发版?
    均可
返回
发新帖