1

I am facing ERR_HTTP2_PROTOCOL_ERROR on my website for some of the files like CSS, and Javascript, I tried clearing the browser cache but it is not working so please do not recommend me this solution. Secondly, I can not clear the cache all the time of my all clients. Please give me a solution based on the web server, I am using NGINX with port forwarding that is my nginx settings

Ngnix configurations:-

        listen 80;
        server_name  mydomain.com;
        return 301 https://dev.mydomain.com$request_uri;
}
# SSL and Proxy Setting
server {
        listen 443 ssl;
        ssl_certificate /etc/ssl/dev.cryptojobs.com/certificate.crt;
        ssl_certificate_key /etc/ssl/dev.cryptojobs.com/private.key;

        server_name dev.mydomain.com
        access_log /var/log/nginx/dev.mydomain.com.access.log;
        error_log /var/log/nginx/dev.mydomain.com.error.log;

        location / {
                proxy_pass         http://127.0.0.1:85;
                proxy_http_version 1.1;
                proxy_set_header   Upgrade $http_upgrade;
                proxy_set_header   Connection keep-alive;
                proxy_set_header   Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Proto $scheme;
                proxy_redirect off;
        }
}```

1 Answers1

0

I was facing the same issue and I fixed this issue by adding gzip, https2 and proxy settings:

However replace your configuration with this and restart your nginx web server:

server {
        listen 80;
        server_name dev.mydomain.com;
        return 301 https://dev.mydomain.com$request_uri;
        
        http2_max_field_size 16k;
}
# SSL and Proxy Setting
server {
        listen 443 ssl http2;
        ssl_certificate /etc/ssl/dev.mydomain.com/certificate.crt;
        ssl_certificate_key /etc/ssl/dev.mydomain.com/private.key;

        server_name dev.cryptojobs.com;
        access_log /var/log/nginx/dev.mydomain.com.access.log;
        error_log /var/log/nginx/dev.mydomain.com.error.log;
        # gzip off;
        gzip on;
        gzip_static on;
        gzip_comp_level 2;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_disable "msie6";
        gzip_min_length 250;
        gzip_proxied no-cache no-store private expired auth;
        gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;

        proxy_max_temp_file_size 0;
        proxy_read_timeout      3600;
        proxy_connect_timeout   300;
        proxy_redirect          off;
        # proxy_http_version 1.1;
        
        location / {
                proxy_cache off;
                proxy_pass         http://127.0.0.1:85;
                # proxy_http_version 1.1;
                proxy_set_header   Upgrade $http_upgrade;
                proxy_set_header   Connection keep-alive;
                proxy_set_header   Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Proto $scheme;
                proxy_redirect off;
        }
}

TechnicalKeera
  • 923
  • 10
  • 20