<div dir="ltr">At the http level:<div><div><br></div><div>map $http_upgrade $connection_upgrade {</div><div> default upgrade;</div><div> '' close;</div><div>}</div></div><div><br></div><div class="gmail_extra">
map $connection_upgrade $proxy_upstream_port {</div><div class="gmail_extra" style> upgrade 81;</div><div class="gmail_extra" style> close 80;</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div>
<div class="gmail_extra">Then at the location do:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra"> location / {</div><div class="gmail_extra"> proxy_http_version 1.1;</div><div class="gmail_extra">
proxy_set_header Upgrade $http_upgrade;</div><div class="gmail_extra"> proxy_set_header Connection $connection_upgrade;</div><div class="gmail_extra" style> proxy_pass http://localhost:$proxy_upstream_port;</div>
<div class="gmail_extra"> }</div><div class="gmail_extra"> </div><div class="gmail_extra" style>Partly taken from <a href="http://nginx.org/en/docs/http/websocket.html">http://nginx.org/en/docs/http/websocket.html</a>.</div>
<div class="gmail_extra"><br></div><div>----appa<br><br></div>
<br><br><div class="gmail_quote">On Thu, May 9, 2013 at 12:35 AM, Alder Network <span dir="ltr"><<a href="mailto:aldernetwork@gmail.com" target="_blank">aldernetwork@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div>This must have been discussed before but I am new to nginx<br>and this forum. <br><br></div><div>I am upgrading to 1.4 to use its websocket proxy feature. <br></div><div>Say I have a websocket server running at port 81, so I want<br>
</div><div>to forward all websocket packets to port 81, and process<br></div><div>the rest at port 80. <br><br></div><div>Somehow the following conf doesn't work, anything missing?<br></div><div><br> server {<br> listen [::]:80 ipv6only=off; <br>
<br> location / {<br> regular_http_processing_directive;<br> <br> if ($http_upgrade = "websocket") {<br> proxy_pass <a href="http://localhost:81" target="_blank">http://localhost:81</a>; <br>
}<br><br> proxy_http_version 1.1;<br> proxy_set_header Upgrade websocket;<br> proxy_set_header Connection upgrade;<br> }<br> }<span class=""><font color="#888888"><br>
</font></span></div><span class=""><font color="#888888"><div><br></div>- Alder<br></font></span></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div></div>