title: Nginx reverse proxy https to https
body: <p>I have a QNAP TS-253A with its admin interface exposed to the internet. </p>
  
  <p>The qnap has it's own certificate installed by a dedicated tool (ie. I don't know exactly where to locate the certificate). </p>
  
  <p><a href="https://mydomain.myqnapcloud.com" rel="nofollow noreferrer">https://mydomain.myqnapcloud.com</a> points to my static IP, and my router has a firewall rule, which forwards port 443 to 192.168.200.6 which is the internal address of my QNAP.</p>
  
  <p>That all works as it should.</p>
  
  <p>Now I have spun up a Docker container on 192.168.200.18, which I would like to expose to <a href="https://identity.someotherdomain.com" rel="nofollow noreferrer">https://identity.someotherdomain.com</a>.</p>
  
  <p>My Idea was to spin up another container with an Nginx reverse proxy (192.168.200.8), and change the firewall rule to forward 443 (and 80) to the reverse proxy. </p>
  
  <p>There are lots of guides to use nginx to sit in front of a http server and add SSL certificate thereby converting an existing http site to https. But my use case should be even simpler as the server i forward to, is already https. </p>
  
  <p>I have tried this, which doesn't work:</p>
  
  <pre><code>upstream qnap {
    server        192.168.200.6:443;
  }
  
  server {
    listen        192.168.200.8:443;
    server_name   mydomainmyqnapcloud.com;
  
    location / {
      proxy_pass  https://qnap;
    }
  }
  </code></pre>
  
  <p>How do I configure nginx to forward traffic intended for <a href="https://mydomain.myqnapcloud.com" rel="nofollow noreferrer">https://mydomain.myqnapcloud.com</a> to <a href="https://192.168.200.6" rel="nofollow noreferrer">https://192.168.200.6</a>
  and traffic intended for <a href="https://identity.someotherdomain.com" rel="nofollow noreferrer">https://identity.someotherdomain.com</a> to <a href="https://192.168.200.18" rel="nofollow noreferrer">https://192.168.200.18</a></p>