6

I recently updated nginx to 1.9.7 which comes with http2 support.

When enabling http2 in one of my vhosts, every page that nginx should be serving from that vhost is instead downloaded. I tested this on the latest version of Chrome, Safari, and Chrome for Android. All had the same result of downloading and saving the page name I navigated to, even if the page didn't actually exist on the server. The page saved on the computer never contained the actual contents of it on the server. It was some weird file that contained the same, weird 1kb string). I tried testing different extensions, to make sure it wasn't an issue with php-fpm, every extension downloaded.

vhost config:

server {
    listen          <ip>:80 http2;
    server_name     testsite.dev;

    index   index.php index.html index.htm;
    root /home/sites/test/www;

    access_log /var/log/nginx/sites/testsite-access_log;
    error_log /var/log/nginx/sites/testsite-error_log;

#   location / {
#               try_files $uri $uri/ /index.php;
#   }

    location = /favicon.ico {
            access_log off;
            log_not_found off;
    }

    gzip off;

    location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/php-fpm/testsite.socket;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param open_basedir "/home/sites:/tmp:/usr/share/pear:/var/lib/php/session/";
    }

}

If I remove the http2 from the listen directive, the site works 100% as expected and serves files normally.

Any insight on why this is happening? Searching google only seems to yield results about .php files being downloading (caused by a mis-configured php-fpm).

Edit: The file that gets downloaded always has this:

When opened in TextEdit:

ġˇˇˇˇˇˇ

When opened in Sublime Text 3:

0000 1204 0000 0000 0000 0300 0000 8000
047f ffff ff00 0500 ffff ff00 0004 0800
0000 0000 7fff 0000 0000 0807 0000 0000
0000 0000 0000 0000 01
5
  • @MichaelHampton Updated the post with some information I forgot to add related to "downloaded". But, downloaded as in saved to the computer's downloads folder much like clicking on a link to a .zip or .gz file. – sodaross Dec 7 '15 at 3:06
  • What was in the downloaded file? – Michael Hampton Dec 7 '15 at 3:18
  • @MichaelHampton What was displayed varied between editors. Added to bottom of post – sodaross Dec 7 '15 at 3:24
  • I strongly suspect you've found a bug in nginx. I would report it as such. – Michael Hampton Dec 7 '15 at 3:31
  • @MichaelHampton Alright, I'll check it out. Thank you for your input and helping! – sodaross Dec 7 '15 at 3:39
11

Generally http2 is expected to run over ssl/tls, both chrome and Firefox only support encrypted http2.

Do you get the same error when adding http/2 to ssl i.e. listen 443 ssl http2

2
  • This actually solved the issue I was having. Using http2 with ssl gives me no unexpected results and works as it should. I was not aware though that http2 would only be supported when used with SSL on browsers. Thank you! – sodaross Dec 10 '15 at 2:48
  • 1
    I would just add that if you happen to have many http 80 server blocks pointing to different websites on the same server machine, you will have to make sure that none of them have http2 assigned. For example: even though you test server block for site www.example.com and there is no http2. It will still give you trouble until you remove http2 from all your server blocks for different websites. – Kenneth Browning Oct 29 '20 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.