# Websocket proxying based on Sec-Websocket-Protocol

**URL:** <https://www.ruby-forum.com/t/websocket-proxying-based-on-sec-websocket-protocol/227555>\
**Category:** NGINX\
**Created:** [March 19, 2013, 11:32am UTC](https://www.ruby-forum.com/t/websocket-proxying-based-on-sec-websocket-protocol/227555 "2013-03-19T11:32:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gvag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cc9497/32.png) [@gvag](https://www.ruby-forum.com/u/gvag)\
**Post date:** [March 19, 2013, 11:32am UTC](https://www.ruby-forum.com/t/websocket-proxying-based-on-sec-websocket-protocol/227555/1 "2013-03-19T11:32:21Z")

</div>

Hi guys,

I am trying to find if it is possible to proxy a websocket request based  
on  
the Sec-Websocket-Protocol. More specific, is there a way to check the  
Sec-Websocket-Protocol  
([RFC 6455 - The WebSocket Protocol](http://tools.ietf.org/html/rfc6455#section-11.3.4))  
header and proxy to the appropriate host/port according to this header?

A use case would be to proxy to a SIP Connector -SIP Websocket  
connector-  
(specific host and port) when the Sec-Websocket-Protocol = sip.  
([draft-ietf-sipcore-sip-websocket-03](http://tools.ietf.org/html/draft-ietf-sipcore-sip-websocket-03))

I checked documentation and forums, but i cannot find any information  
relevant to this issue. As far as i can see the Sec-Websocket-Protocol  
header is not available to be used in the nginx, just the “Upgrade:  
websocket” header.

Regards  
George

Posted at Nginx Forum:

> **[Websocket proxying based on Sec-Websocket-Protocol](https://forum.nginx.org/read.php?2,237539,237539#msg-237539)**
>
> Hi guys, I am trying to find if it is possible to proxy a websocket request based on the Sec-Websocket-Protocol. More specific, is there a way to check the Sec-Websocket-Protocol (http://tools.ietf.org/html/rfc6455#section-11.3.4) header and proxy to...

---

<div class="post-metadata">

**Author:** ![gvag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cc9497/32.png) [@gvag](https://www.ruby-forum.com/u/gvag)\
**Post date:** [March 19, 2013, 2:35pm UTC](https://www.ruby-forum.com/t/websocket-proxying-based-on-sec-websocket-protocol/227555/2 "2013-03-19T14:35:49Z")

</div>

Hello!

On Tue, Mar 19, 2013 at 06:32:04AM -0400, gvag wrote:

> I checked documentation and forums, but i cannot find any information  
> relevant to this issue. As far as i can see the Sec-Websocket-Protocol  
> header is not available to be used in the nginx, just the “Upgrade:  
> websocket” header.

You may check Sec-Websocket-Protocol using  
$http\_sec\_websocket\_protocol variable (see [1]) and route requests  
accordingly. This isn’t specific to websockets and hence not  
something discussed in websockets context.

[1] [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#variables)

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![gvag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cc9497/32.png) [@gvag](https://www.ruby-forum.com/u/gvag)\
**Post date:** [March 19, 2013, 3:48pm UTC](https://www.ruby-forum.com/t/websocket-proxying-based-on-sec-websocket-protocol/227555/3 "2013-03-19T15:48:54Z")

</div>

Thanks a lot for the answer.

George

Posted at Nginx Forum:

> **[Re: Websocket proxying based on Sec-Websocket-Protocol](https://forum.nginx.org/read.php?2,237539,237559#msg-237559)**
>
> Hi guys, I am trying to find if it is possible to proxy a websocket request based on the Sec-Websocket-Protocol. More specific, is there a way to check the Sec-Websocket-Protocol (http://tools.ietf.org/html/rfc6455#section-11.3.4) header and proxy to...
