title: Nginx websocket proxy
body: <p>I'm trying to use nginx to proxy websocket requests using a regularexpression as follows:</p>
  
  <pre><code>server {
              listen 9092;
              server_name ~^(?&lt;pc_name&gt;.*)\.(.*)$;
              location / {
                      include proxy_params;
                      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                      proxy_set_header        X-Forwarded-Proto $scheme;
                      proxy_pass http://$pc_name:9092;
                      proxy_http_version 1.1;
                      proxy_set_header Upgrade $http_upgrade;
                      proxy_set_header Connection $connection_upgrade;
              }
      }
  
      map $http_upgrade $connection_upgrade {
              default upgrade;
              ''      close;
      }
  </code></pre>
  
  <p>and it's not working like that, i'm getting errors about not being able to resolve the host if i try to access pc-addr.localhost:9092 i get the error:</p>
  
  <pre><code>2017/08/07 08:42:37 [error] 22021#22021: *2 no resolver defined to resolve pc-addr, client: 127.0.0.1, server: ~^(?&lt;pc_name&gt;.*)\.(.*)$, request: "GET / HTTP/1.1", host: "pc-addr.localhost:9092"
  </code></pre>
  
  <p>However, if I replace the variable name with with pc-addr directly (i.e. all requests will be forwarded to pc-add:9092) it works fine and the requests are proxied as expected</p>
  
  <pre><code>server {
              listen 9092;
              server_name ~^(?&lt;pc_name&gt;.*)\.(.*)$;
              location / {
                      include proxy_params;
                      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                      proxy_set_header        X-Forwarded-Proto $scheme;
                      proxy_pass http://pc-addr:9092;
                      proxy_http_version 1.1;
                      proxy_set_header Upgrade $http_upgrade;
                      proxy_set_header Connection $connection_upgrade;
              }
      }
  
      map $http_upgrade $connection_upgrade {
              default upgrade;
              ''      close;
      }
  </code></pre>