title: Two Nginx instances, listening to different ports, only one reachable by domain
body: <p>I use docker-compose stacks to run things on my personal VPS. Right now, I have a stack that's composed of:</p>
  
  <ul>
  <li>Nginx (exposed port 443)</li>
  <li>Ghost (blogging)</li>
  <li>MySQL (for Ghost)</li>
  <li>Adminer (for MySQL, exposed port 8080)</li>
  </ul>
  
  <p>I wanted to try out Matomo analytics software, but I didn't want to add that to my current stack until I was happy with it, so I decided to create a second docker-compose stack for just the Matomo analytics:</p>
  
  <ul>
  <li>Nginx (exposed port 444)</li>
  <li>Matomo</li>
  <li>MariaDB (for Matomo)</li>
  <li>Adminer (for MariaDB, exposed port 8081)</li>
  </ul>
  
  <p>With both stacks running, I can access everything at its appropriate port, but only by IP address. If I try to use my domain, it can only connect to the first Nginx, the one exposing port 443. If I try <code>https://www.example.com:444</code> in my browser, it isn't able to connect. If I try <code>https://myip:444</code> in my browser, it connects to the second Nginx instance exposing port 444, warning me that the SSL certificate has issues (since I'm connecting to my IP, not my domain), and then lets me through.</p>
  
  <p>I was wondering if anyone knew why this behavior was happening. I'm admittedly new to setting up VPSs, using Nginx to proxy to other hosted services, etc. If it turns out Nginx cannot be used this way, I'd love to hear recommendations on how else I could arrange this. (Do I have to only have one Nginx instance running at a time, and I must proxy through it to everything else? etc)</p>
  
  <p>Thank you!</p>