首页 > 解决方案 > net::ERR_HTTP2_PROTOCOL_ERROR 200 渲染大型 html 文件时

问题描述

我在 nginx 和 Cloudflare 后面有一个 golang 应用程序,它提供大型 html 文件,但我注意到对于 GET 请求,在大约 900KB 大小之后,html 被截断并且页面的按钮不显示。

Firefox 和 Chrome 都存在这个问题。在 Chrome 控制台中,我得到:

net::ERR_HTTP2_PROTOCOL_ERROR 200

这是我的 nginx.conf 相关部分

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        types_hash_max_size 2048;
        client_body_buffer_size 10K;
        client_header_buffer_size 1k;
        client_max_body_size 8m;
        large_client_header_buffers 2 1k;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        client_body_timeout 12;
        client_header_timeout 12;
        keepalive_timeout 15;
        send_timeout 10;
        
   gzip on;
   gzip_disable "msie6";
   gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_buffers 32 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

我增加gzip_buffers16 4kto32 8k甚至禁用了 gzip 压缩,但这些并没有解决问题。

感谢您解决此问题的提示。

标签: htmlgonginx

解决方案


推荐阅读