title: Nginx, how to allow DOMAIN:PORT and IP:PORT requests
body: <p>What's the proper way to configure Nginx to allow DOMAIN:PORT requests like this:</p>
  
  <pre><code>http://example.com:8080/?a=xxx&amp;b=yyy&amp;c=zzz
  over TCP or UDP
  </code></pre>
  
  <p>And IP:PORT requests like this:</p>
  
  <pre><code>http://1.2.3.4:8086/?a=xxx&amp;b=yyy&amp;c=zzz
  over TCP or UDP
  </code></pre>
  
  <p>Nginx also must allow domain requests like these, which already work correctly on my setup:</p>
  
  <pre><code>http://example.com/home
  http://example.com/work
  over TCP
  </code></pre>
  
  <p>For the IP:PORT requests, I tried this config, but it didn't work:</p>
  
  <pre><code>server {
      listen 8080;
      server_name 1.2.3.4:8080;
      root /home/public_html/example.com;
  
      location / {
          client_max_body_size 10m;
          client_body_buffer_size 20m;
          proxy_connect_timeout 10s;
          proxy_send_timeout 5s;
          proxy_read_timeout 60s;
          proxy_buffer_size 8k;
          proxy_buffers 4 64k;
          proxy_busy_buffers_size 128k;
          proxy_temp_file_write_size 128k;
          proxy_redirect off;
          proxy_pass http://1.2.3.4:8080;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
  }
  </code></pre>
  
  <hr>
  
  <h2>Added for steve klein</h2>
  
  <pre><code>server {
      # HTTP IP:PORT ...
      # http://example.com:8080/app/?ip=1.2.3.4&amp;pt=55555&amp;do=things
      # there's a listener on port 55555
      #
      listen 8080;
      server_name example.com www.example.com;
      root /home/public_html/example.com;
  
      location /app {
          client_max_body_size 128k;
          client_body_buffer_size 256k;
          proxy_connect_timeout 10s;
          proxy_send_timeout 5s;
          proxy_read_timeout 60s;
          proxy_buffer_size 8k;
          proxy_buffers 4 64k;
          proxy_busy_buffers_size 128k;
          proxy_temp_file_write_size 128k;
          proxy_ignore_client_abort on;
          proxy_pass http://$arg_ip:$arg_pt;
          proxy_redirect off;
      }
  }
  </code></pre>