AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[mod-pagespeed](server)

Martin Hope
user64675
Asked: 2020-03-23 19:37:10 +0800 CST

如何在第一页加载(SSL + Pagespeed)上解决静态文件的 ERR_HTTP2_PROTOCOL_ERROR?

  • 0

我有一个 nginx HTTP2 + ngx_pagespeed + brotli + Wordpress W3 Total Cache 设置。在第一页加载一些由 Pagespeed 修改的静态文件无法加载,给出 ERR_HTTP2_PROTOCOL_ERROR。

最初我认为这是 W3 Total Cache 错误,在重新加载缓存页面后一切似乎都加载正常。是 Pagespeed 搞砸了还是我的 SSL 设置有误?

我的网站配置:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name mywebsite.com www.mywebsite.com;

    root /srv/mywebsite.com/www/;
    index index.php index.html index.htm;
    error_log /srv/mywebsite.com/log/error.log;

    keepalive_timeout 60;

    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;
    ssl_dhparam /etc/nginx/ssl/dhparam.pem;
    ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
    ssl_ecdh_curve secp384r1;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_stapling on;
    ssl_stapling_verify on;

    ssl_trusted_certificate /etc/letsencrypt/live/mywebsite.com/chain.pem;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;
    ssl_session_tickets off;
    ssl_prefer_server_ciphers on;
    ssl_buffer_size 4k;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    pagespeed on;
    pagespeed Domain http://mywebsite.com;
    pagespeed Domain https://mywebsite.com;
    pagespeed MapOriginDomain localhost https://mywebsite.com;
    pagespeed LoadFromFile https://mywebsite.com /srv/mywebsite.com/www/;
    pagespeed FileCachePath /var/cache/pagespeed;
    pagespeed EnableFilters prioritize_critical_css,extend_cache,rewrite_javascript,rewrite_css,convert_jpeg_to_progressive,convert_jpeg_to_webp,convert_png_to_jpeg,convert_to_webp_lossless,recompress_jpeg,recompress_png,recompress_webp,jpeg_subsampling,resize_images,strip_image_color_profile,strip_image_meta_data,inline_images;
    pagespeed PreserveUrlRelativity on;
    pagespeed XHeaderValue "Powered By ngx_pagespeed";
    pagespeed ImplicitCacheTtlMs 2592000000;
    pagespeed LoadFromFileCacheTtlMs 2592000000;

    # BEGIN W3TC Page Cache core
    set $w3tc_rewrite 1;
    if ($request_method = POST) {
        set $w3tc_rewrite 0;
    }
    if ($query_string != "") {
        set $w3tc_rewrite 0;
    }
    if ($request_uri !~ \/$) {
        set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") {
        set $w3tc_rewrite 0;
    }
    set $w3tc_preview "";
    if ($http_cookie ~* "(w3tc_preview)") {
        set $w3tc_preview _preview;
    }
    set $w3tc_ssl "";
    if ($scheme = https) {
        set $w3tc_ssl _ssl;
    }
    if ($http_x_forwarded_proto = 'https') {
        set $w3tc_ssl _ssl;
    }
    set $w3tc_enc "";
    #if ($http_accept_encoding ~ gzip) {
    #    set $w3tc_enc _gzip;
    #}
    set $w3tc_ext "";
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.html$w3tc_enc") {
      set $w3tc_ext .html;
    }
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.xml$w3tc_enc") {
        set $w3tc_ext .xml;
    }
    if ($w3tc_ext = "") {
        set $w3tc_rewrite 0;
    }
    if ($w3tc_rewrite = 1) {
        rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview$w3tc_ext$w3tc_enc" last;
    }
    # END W3TC Page Cache core

    # BEGIN W3TC Page Cache cache
    location ~ /wp-content/cache/page_enhanced.*html$ {
        expires modified 3600s;
        add_header Vary "Accept-Encoding, Cookie";
        add_header Pragma "public";
        add_header Cache-Control "public";
    }
    location ~ /wp-content/cache/page_enhanced.*gzip$ {
        brotli off;
        gzip off;
        types {
            text/xml xml_gzip;
        }
        default_type text/html;
        expires modified 3600s;
        add_header Vary "Accept-Encoding, Cookie";
        add_header Pragma "public";
        add_header Cache-Control "public";
        add_header Content-Encoding gzip;
    }
    # END W3TC Page Cache cache

    location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
      add_header "" "";
    }
    location ~ "^/pagespeed_static/" { }
    location ~ "^/ngx_pagespeed_beacon$" { }

    # BEGIN W3TC Browser Cache
    pagespeed HttpCacheCompressionLevel 0;
    gzip on;
    gzip_vary on;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access video/webm application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel;
    location ~ \.(css|htc|less|js|js2|js3|js4)$ {
        expires 31536000s;
        etag off;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "public";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    location ~ \.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$ {
        expires 3600s;
        etag off;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "public";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|rss|atom|gif|tgz|gz|rar|gzip|bz2|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$ {
        expires 31536000s;
        etag off;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "public";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    add_header Referrer-Policy "";
    # END W3TC Browser Cache

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param DOCUMENT_ROOT /srv/mywebsite.com/www/;
        fastcgi_param SCRIPT_FILENAME /srv/mywebsite.com/www$fastcgi_script_name;
        fastcgi_param PATH_TRANSLATED /srv/mywebsite.com/www$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param HTTPS on;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 8 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
}
ssl nginx http2 mod-pagespeed
  • 1 个回答
  • 3344 Views
Martin Hope
dubesor
Asked: 2016-08-11 11:26:40 +0800 CST

mod_pagespeed : 安装与 libc6 2.13 (Debian Wheezy) 兼容的早期版本

  • 0

可能是一个愚蠢的问题,但我怎样才能在当前稳定/测试版本之前获得 mod_pagespeed 版本的 _amd64.deb 包版本 - 即版本1.11.33.0 - beta - https://github.com/pagespeed/mod_pagespeed/树/1.11.33.0

我需要在我的 Debian Wheezy 服务器上安装 mod_pagespeed,但当前版本不支持它(libc6 版本依赖项现在是 2.14,而 Wheezy 有 2.13)。在这个重要的生产网络服务器上,从源代码构建 mod_pagespeed 或以某种方式更新 libc6 并不是一个很好的选择。

我很想简单地抓取和 dpkg 还不需要 glibc >= 2.14 的最新版本,并且会在 Debian Wheezy 7.0 上 dpkg 而不会引发依赖错误,例如:

sudo dpkg -i mod-pagespeed-stable_current_amd64.deb
Selecting previously unselected package mod-pagespeed-stable.
(Reading database ... 40509 files and directories currently installed.)
Unpacking mod-pagespeed-stable (from mod-pagespeed-stable_current_amd64.deb) ...
dpkg: dependency problems prevent configuration of mod-pagespeed-stable:
mod-pagespeed-stable depends on libc6 (>= 2.14); however:
Version of libc6:amd64 on system is 2.13-38+deb7u7.

发行说明说支持此设置的最后一个版本只是几个版本 - glibc 2.14 要求在 2016 年 5 月的 v 1.11.33.1-stable 中已经到位,因此 1.11.33.0-beta 应该可以解决问题。

那里有旧的 .deb 包的存档吗?或者使用 wget 时在 URL 结构中引用版本的方法 - 即https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed- ???? _amd64.deb

linux debian apache-2.2 web-server mod-pagespeed
  • 1 个回答
  • 1603 Views
Martin Hope
webjay
Asked: 2012-06-19 14:21:04 +0800 CST

一段时间后 mod_pagespeed 忘记了优化

  • 0

我已经设置了 mod_pagespeed,它似乎工作正常,但只有在我重新加载页面时才会这样。几分钟后,优化消失了。

这是一个静态站点,只有在您重新加载页面时才会进行全面优化: twitterbogen.dk

在第一次加载时,CSS 文件没有 .pagespeed。在他们中。如果您重新加载,他们会这样做。知道为什么吗?

这是我的Apache 服务器信息。

这是我的 mod_pagespeed 配置:

ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath            "/var/www/mod_pagespeed/cache/"
ModPagespeedGeneratedFilePrefix      "/var/www/mod_pagespeed/files/"
ModPagespeedEnableFilters rewrite_javascript,rewrite_css
ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters extend_cache,combine_css,move_css_above_scripts,move_css_to_head,inline_css,inline_import_to_link,flatten_css_imports,inline_javascript,outline_javascript,rewrite_style_attributes,rewrite_images,sprite_images
ModPagespeedAvoidRenamingIntrospectiveJavascript on
ModPagespeedMessageBufferSize 100000
apache-2.2 mod-pagespeed
  • 1 个回答
  • 342 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve