title: nginx reverse proxy multiple different backends
body: <p>I have a nginx reverse Proxy, which servers multiple external domains from outside. The nginx will pass requests on Port 80 as follows to the backends</p>
  <blockquote>
  <p><a href="http://server1.domain.com" rel="nofollow noreferrer">http://server1.domain.com</a>   ---&gt; <a href="http://backend1.domain.com" rel="nofollow noreferrer">http://backend1.domain.com</a></p>
  <p><a href="http://server2.domain.com" rel="nofollow noreferrer">http://server2.domain.com</a>   ---&gt; <a href="http://backend2.domain.com" rel="nofollow noreferrer">http://backend2.domain.com</a></p>
  <p><a href="http://server3.domain.com" rel="nofollow noreferrer">http://server3.domain.com</a>   ---&gt; <a href="http://backend3.domain.com" rel="nofollow noreferrer">http://backend3.domain.com</a></p>
  </blockquote>
  <p>Now the strange behaviour. I have one conf file in sites-enabled. like test.conf. In this conf file only one backend with only one externe is configured like this:</p>
  <pre><code>server {
  server_name server1.domain.com;
  listen server1.domain.com:80;
  
   location ~ {
    proxy_pass_header Authorization;
    proxy_pass http://backend1.domain.com:80;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Connection &quot;&quot;;
    proxy_buffering off;
    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
   }
  
   access_log /var/log/nginx/http_access.log;
   error_log  /var/log/nginx/http_error.log;
  
   }
  </code></pre>
  <p>So as you can see the config, only one backend is configured. BUT if I call <a href="http://server2.domain.com" rel="nofollow noreferrer">http://server2.domain.com</a> or <a href="http://server3.domain.com" rel="nofollow noreferrer">http://server3.domain.com</a> etc, it will still forward me to the CORRECT backend servers, even if I have configured just one?????. This seems to me very very strange.</p>
  <p>on the other hand I can proxy with the stream ssl_preload module on port 443 or any other port just fine. So when I remove one of the servers from the map directive, it will not route to the backend. This situation is just OK. My main concern is the Port 80 acting so strange, why???!!??</p>