0

Inside NGINX config file:

http {

        server {
                listen 80;
                server_name sample.com;

                location / {
                        proxy_pass http://127.0.0.1:8080;
                }
        }

        server {
                listen 80;
                server_name example.com;

                location / {
                        proxy_pass http://127.0.0.1:8081;
                }
        }
}

The above config works fine and web browser is able to access websites and show their content.

But, when I change listen 80; statement to listen 80 http2;, the web browser downloads a file rather than showing webpages of sample.com and example.com. Why is that?

Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 1
    Maybe because the browser doesn't support http2 without tls, as mentioned in this thread: https://stackoverflow.com/questions/46788904/why-do-web-browsers-not-support-h2c-http-2-without-tls – Đăng Khoa Đinh Apr 25 '21 at 06:49
  • @ĐăngKhoaĐinh Seems like that's the answer! =) – Megidd Apr 25 '21 at 07:45

1 Answers1

0

Content-Type: text/html should in Response Headers (like below)

Maybe you should config http2's Response Headers

enter image description here

Zhefang Wu
  • 19
  • 6