3

I want to direct to any http2 url. I tried two ways for this.

1)

My nginx file;

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

                ssl on;
                ssl_certificate /etc/ssl/secure.crt;
                ssl_certificate_key /etc/ssl/secure.key;

                server_name _;
                root /var/www/example;
                index index.html index.html;

                location / {
                        try_files $uri $uri/ /index.html;
                }
                location /api/get {
                        return 301  https://app_service;
                }

}

I get error net::ERR_CERT_AUTHORITY_INVALID

2)

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

                    ssl on;
                    ssl_certificate /etc/ssl/secure.crt;
                    ssl_certificate_key /etc/ssl/secure.key;

                    server_name _;
                    root /var/www/example;
                    index index.html index.html;

                    location / {
                            try_files $uri $uri/ /index.html;
                    }
                    location /api/get {
                            proxy_pass  https://app_service;
                    }

    }

I get error 502 Bad Gateway and

in /var/log/nginx/error.log *2 upstream prematurely closed connection while reading response header from upstream

How can I solve this problem? Which method is more accurate?

Arya
  • 43
  • 1
  • 6
  • What is the output of `$ sudo nginx -t`? can you check and post it here if you get errors? – ROOT Jan 27 '20 at 14:05
  • There are no errors. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful – Arya Jan 28 '20 at 06:40
  • The error you get seems to be related to your app server, does your app server support http2? check this for more information: https://stackoverflow.com/questions/36488688/nginx-upstream-prematurely-closed-connection-while-reading-response-header-from – ROOT Jan 28 '20 at 09:21

0 Answers0