<div dir="ltr">I changed the configuration to :<div><br></div><div><div> location /hello {</div><div> hello;</div><div> proxy_set_header X-Real-IP $remote_addr;</div><div> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</div>
<div> proxy_set_header Host $http_host;</div><div> proxy_set_header X-NginX-Proxy true;</div><div> proxy_pass <a href="http://localhost:80">http://localhost:80</a>;</div><div> proxy_http_version 1.1;</div>
<div> proxy_set_header Upgrade $http_upgrade;</div><div> proxy_set_header Connection "upgrade";</div><div> proxy_set_header Host $host;</div><div> }</div><div><br></div><div>
<br></div><div><br></div><div style>With a helllo module compiled in and when I send the GET request with upgrade connection for protocol swicth,</div><div style>although I do not get 502 error for BAD_GATEWAY but I end up having normal 200k instead of</div>
<div style>protocol switch 101 response.</div><div style><br></div><div style>Please suggest, where I am going wrong.</div><div style><br></div><div style>Thanks</div><div style>Hemant</div><div><br></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Oct 18, 2013 at 7:09 PM, Hemant Kumar <span dir="ltr"><<a href="mailto:mailtohemantkumar@gmail.com" target="_blank">mailtohemantkumar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi All<div><br></div><div>I am a newbie with nginx server. I am trying to get websocket configuration working on cent-os.(linux 2.6.32-358.18.1.el6.x86_64). Following is my nginx config file;</div><div><br>
</div>
<div><div>http {</div><div> include mime.types;</div><div> default_type application/octet-stream;</div><div><br></div><div> #log_format main '$remote_addr - $remote_user [$time_local] "$request" '</div>
<div> # '$status $body_bytes_sent "$http_referer" '</div><div> # '"$http_user_agent" "$http_x_forwarded_for"';</div><div><br></div><div>
#access_log logs/access.log main;</div><div><br></div><div> sendfile on;</div><div> #tcp_nopush on;</div><div><br></div><div> #keepalive_timeout 0;</div><div> keepalive_timeout 65;</div><div>
<br></div><div> #gzip on;</div><div><br></div><div> server {</div><div> listen 80;</div><div> server_name localhost;</div><div><br></div><div> #charset koi8-r;</div><div><br></div><div>
#access_log logs/host.access.log main;</div>
<div><br></div><div> location / {</div><div> root html;</div><div> index index.html index.htm;</div><div> <b> proxy_pass <a href="http://localhost:80" target="_blank">http://localhost:80</a></b>;</div>
<div> proxy_http_version 1.1;</div><div> <b>proxy_set_header Upgrade $http_upgrade;</b></div><div><b> proxy_set_header Connection "upgrade";</b></div><div><b> proxy_set_header Host $host;</b></div>
<div> proxy_read_timeout 3600;</div><div> proxy_send_timeout 3600;</div><div> }</div><div><br></div><div> #error_page 404 /404.html;</div><div> location / {</div>
<div>
# root html;</div><div> # index index.html index.htm;</div><div> # }</div><div> #}</div><div><br></div><div><br></div><div> # HTTPS server</div><div> #</div><div> #server {</div>
<div>
# listen 443;</div><div> # server_name localhost;</div><div><br></div><div> # ssl on;</div><div> # ssl_certificate cert.pem;</div><div> # ssl_certificate_key cert.key;</div>
<div><br></div><div> # ssl_session_timeout 5m;</div><div><br></div><div> # ssl_protocols SSLv2 SSLv3 TLSv1;</div><div> # ssl_ciphers HIGH:!aNULL:!MD5;</div><div> # ssl_prefer_server_ciphers on;</div>
<div><br></div><div> # location / {</div><div> # root html;</div><div> # index index.html index.htm;</div><div> # }</div><div> #}</div><div><br></div><div>}</div><div><br></div><div>
<br>
</div><div>With above configuration, and with proxy_pass set, it gices 502 error. When I try to access </div><div>ws://<a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a> using chrome websocket client.</div><div>
<br></div><div>I will highly appreciate if someone can give right pointer to resolving this.</div><div><br></div><div>Thanks a ton</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Hemant</div><div><br>
</div></font></span></div></div>
</blockquote></div><br></div>