title: nginx proxy_pass to dynamic url
body: <p>I have multiple backend servers and I want to proxy all servers using a single nginx server instance. I don't want to change nginx.conf whenever I add a new backend server. </p>
  
  <p>For example: Server 1 : 192.168.10.1:8080, Server2: 192.168.10.2:8080, etc
  Nginx is running on <a href="http://example.com" rel="nofollow noreferrer">example.com</a>. I want to access Server1 by using <a href="http://example.com?ip=192.168.10.1" rel="nofollow noreferrer">example.com?ip=192.168.10.1</a>, <a href="http://example.com?ip=192.168.10.2" rel="nofollow noreferrer">example.com?ip=192.168.10.2</a> etc</p>
  
  <p>I tried this configuration, but it is giving 500 error page.</p>
  
  <pre><code>location / {
     proxy_pass http://$arg_ip:8080;
     proxy_set_header Host      $host;
     proxy_set_header X-Real-IP $remote_addr;
  }
  </code></pre>
  
  <p>Is there something I am missing? Is there any other way of achieving this?</p>