title: SSL Certificate Invalid on back end Node App (Nginx Reverse Proxy)
body: <p>So I'm having some issues with SSL certificates.</p>
  
  <p>I have a react app running on port 80.
  and a node backend running on port 443.</p>
  
  <p>I have a domain pointing to the IP (xx.xx.xxx.xx) which directs to the react app. I'm using nginx to proxy the requests from frontend to backend as I have both on the same server.</p>
  
  <p>Here is the nginx config:</p>
  
  <pre><code>server {
    listen 80 ssl;
    server_name xx.xx.xxx.xx;
    ssl_client_certificate /etc/letsencrypt/live/domain.com/cert.pem;
    ssl_certificate /etc/letsencrypt/live/domain.com/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
    root /home/ubuntu/build;
    index index.html;
  
    access_log /var/log/nginx/build.access.log;
    error_log /var/log/nginx/build.error.log;
    location / {
      try_files $uri /index.html =404;
    }
  }
  
  upstream backend {
    server 127.0.0.1:443;
    server 127.0.0.1:443 max_fails=1 fail_timeout=30s backup;
    keepalive 64;
  }
  
  server {
    listen 443 ssl;
    server_name xx.xx.xxx.xx;
    ssl_client_certificate /etc/letsencrypt/live/domain.com/cert.pem;
    ssl_certificate /etc/letsencrypt/live/domain.com/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
    keepalive_timeout 10;
    location / {
      proxy_pass http://backend;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
      proxy_set_header Connection '';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
      proxy_redirect off;
     }
  }
  </code></pre>
  
  <p>I'm receiving the following error when a request is made to the backend:</p>
  
  <blockquote>
    <p>net::ERR_CERT_COMMON_NAME_INVALID</p>
  </blockquote>
  
  <p>this is because the certificate is valid for 'domain.com' and not the IP that the backend is operating on (I know you must use a fully qualified domain for the cert).</p>
  
  <p>My question is what can I do differently (with nginx) that will allow my requests to be made over https on a reverse proxy?</p>