title: How to correctly deploy/setup NestJS backend using Nginx?
body: <p>I'm trying to deploy my webapplication using Angular and NestJs using Nginx on an Ubuntu remote server.
  I got the frontend working on <a href="https://ikse.fransenit.nl/products" rel="nofollow noreferrer">https://ikse.fransenit.nl/products</a> 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.</p>
  <p>When starting the NestJS backend:
  <a href="https://i.stack.imgur.com/McHIH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McHIH.png" alt="nestjs starting" /></a></p>
  <h3>nginx config</h3>
  <pre><code>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
  }
  </code></pre>
  <p>What am I missing and/or doing wrong?</p>