title: nginx reverse proxy stop port override
body: <p>I am using nginx currently to run two node apps on one vps. It's working however, from either URL, if I manually enter the port of the other it will run the other app, ie going to mydomain1.com and mydomain2.com correctly routes to node apps running on ports 1337 and 1338. However I can do mydomain1.com:1337 or mydomain1.com:1338 and I can access either app, this doesn't seem correct. Can I, and if so how, prevent appending the port to cross access apps?</p>
  
  <p>Here are my files located in etc/nginx/conf.d, mydomain1.conf and mydomain2.conf:</p>
  
  <p>mydomain1.conf</p>
  
  <pre><code>    server {
          listen 80;
  
          server_name mydomain1.com;
  
          location / {
              proxy_pass http://localhost:1337;
              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;
          }
      }
  </code></pre>
  
  <p>mydomain2.conf</p>
  
  <pre><code>    server {
          listen 80;
  
          server_name mydomain2.com;
  
          location / {
              proxy_pass http://localhost:1338;
              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;
          }
      }
  </code></pre>
  
  <p>I also added a /etc/nginx/nginx.conf file with the following contents:</p>
  
  <pre><code>    server_names_hash_bucket_size 64;
  </code></pre>