I have configured my website to run on an HTTPS certificate and the front end is served perfectly from the/var/www/application/pwa location. I have a node server running with the help of pm2 process and is running on port 8000(http://localhost.com:8000). The ubuntu server has ports 80, 443 and 8000 enabled. But with the following nginx configuration the API calls are giving the ERR_SSL_PROTOCOL_ERROR.
NGINX Configuration:
server { listen 443 ssl http2; # managed by Certbot listen [::]:443 ssl http2; server_name domain.com www.domain.com; # Root directory for your website files root /var/www/application/pwa; # Index file to serve index index.html; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot # Location block for handling requests location /api { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_max_temp_file_size 0; proxy_pass http://localhost.com:8000; proxy_redirect off; proxy_read_timeout 240s; }}server { listen 80; server_name domain.com www.domain.com; # Redirect HTTP requests to HTTPS return 301 https://$server_name$request_uri; # Index file to serve index index.html; location / { return 301 https://$host$request_uri; }}
The following error that the API throws:
Is there anything missing or wrong in the nginx configuration?