title: Nginx will not start with host not found in upstream
body: <p>I use nginx to proxy and hold persistent connections to far away servers for me.</p>
  
  <p>I have configured about 15 blocks similar to this example:</p>
  
  <pre><code>upstream rinu-test {
      server test.rinu.test:443;
      keepalive 20;
  }
  server {
      listen 80;
      server_name test.rinu.test;
      location / {
          proxy_pass https://rinu-test;
          proxy_http_version 1.1;
          proxy_set_header Connection "";
          proxy_set_header Host $http_host;
      }
  }
  </code></pre>
  
  <p>The problem is if the hostname can not be resolved in one or more of the <code>upstream</code> blocks, nginx will not (re)start. I can't use static IPs either, some of these hosts explicitly said not to do that because IPs will change. Every other solution I've seen to this error message says to get rid of <code>upstream</code> and do everything in the <code>location</code> block. That it not possible here because <code>keepalive</code> is only available under <code>upstream</code>.</p>
  
  <p>I can temporarily afford to lose one server but not all 15.</p>
  
  <p>Edit:
  Turns out nginx is not suitable for this use case. An alternative backend (upstream) keepalive proxy should be used. A custom Node.js alternative is in <a href="https://stackoverflow.com/a/50373442/3232922">my answer</a>. So far I haven't found any other alternatives that actually work.</p>