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?