0

Im using a dev enviroment with vagrant, running nginx, fpm and php 8.

The site runs fine with http1.1 but when I try to enable http2 in my nginx config I get this error in chrome.

Chrome error

And when I load the same page on firefox It loads fine with a 200 with HTTP2

Firefox ok

This is my nginx config for the dev site.

server {
  listen 127.0.0.1:9080;
  server_name localhost DOMAIN;
  root /var/www/techship/public;

  access_log /var/www/techship/log/access.log;
  client_max_body_size 1G;

  expires 0;

  location ~ \..*/.*\.php$ {
    return 403;
  }

  location ~* (.+)\.(\d+)\.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 0;
    try_files $uri $1.$3;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/run/php/php8.0-fpm.sock;
  }
}

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

  ssl_certificate certificates/dev.techship.crt;
  ssl_certificate_key certificates/dev.techship.key;

  ssl_session_timeout 1h;
  ssl_session_cache shared:SSL:16m;

  ssl_protocols TLSv1.3;
  ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;

  client_max_body_size 1G;

  expires 0;

  location / {
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Client-Verify SUCCESS;
    proxy_set_header X-SSL-Subject $ssl_client_s_dn;
    proxy_set_header X-SSL-Issuer $ssl_client_i_dn;
    proxy_set_header HTTPS on;

    proxy_pass http://127.0.0.1:9080;
  }
}

Removing the http2 directive and everything works again.

Any ideas why chrome gets this error, while firefox is working?

EDIT:

A incorrectly set header of "Last Modified" (should be "Last-Modified") was set by my PHP backend. I guess Chrome is being strict about incorrect headers and firefox is not.

asegestam
  • 11
  • 4
  • [This answer](https://stackoverflow.com/a/66558180/3081018) on the linked question describes a similar problem. It might help in your case. If not you likely need to provide more information, so that others can reproduce your issue. – Steffen Ullrich Sep 01 '21 at 10:11
  • Good suggestion, but went over the headers thats being set from PHP and none have this issue. – asegestam Sep 01 '21 at 11:53
  • I'm pretty sure that the configuration you show is not the problem. This means the problem is outside of what you show in your question. Without more information the question can not be answered but one can only wildly speculate what the reason might be - like I tried by finding a similar question. If the site is public accessible one useful information would be to provide the actual URL, so that others can try to reproduce the issue. – Steffen Ullrich Sep 01 '21 at 12:03
  • You are right - I ignored the nginx config part and focused on the PHP backend. Found a place where a Last-Modified header was being set, commented it out and it worked in Chrome aswell. Not sure why this triggers a protocol error however – asegestam Sep 01 '21 at 12:33
  • My guess is that the Last-Modified header had the wrong syntax, like using "Last Modified" instead of "Last-Modified" (invalid space in header name instead of valid dash) – Steffen Ullrich Sep 01 '21 at 12:34
  • 1
    Haha wow Im blind, and you are right. Its being set as "Last Modified" not "Last-Modified". Guess Chrome with HTTP/2 is more strict and triggers an error when a header is incorrect. – asegestam Sep 01 '21 at 12:41

0 Answers0