I'm trying to deploy my webapplication using Angular and NestJs using Nginx on an Ubuntu remote server. I got the frontend working on https://ikse.fransenit.nl/products but cannot get the backend to work. It was working fine locally. When I try to go to /api/products I get a 502 bad gateway.
When starting the NestJS backend:
nginx config
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/ikse/html;
server_name ikse.fransenit.nl www.ikse.fransenit.nl;
index index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# proxy_pass http://localhost:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
}
location /api/ {
proxy_pass https://localhost:3000;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ikse.fransenit.nl/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ikse.fransenit.nl/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
}
What am I missing and/or doing wrong?