Websocket, set Sec-Websocket-Protocol

Francis Daly francis at daoine.org
Sat Mar 4 08:26:15 UTC 2017

On Fri, Feb 24, 2017 at 01:24:11AM -0500, ashoba wrote:

Hi there,

> How I can set Sec-WebSocket-Protocol in config?
> I've tried  proxy_set_header Sec-WebSocket-Protocol "v10.stomp, v11.stomp";
> and add_header Sec-WebSocket-Protocol "v10.stomp, v11.stomp".
> In response, I'm not getting 'Sec-WebSocket-Protocol' header.

If you want to add a header to the response that nginx sends to a client
using stock nginx, "add_header" (http://nginx.org/r/add_header) is the
directive to use.

That directive needs to apply within the location{} that nginx uses to
handle the request that you make. And it only applies to certain http
response codes, per the documentation.

What is the config that you use that gives a response that you do
not want?

(There is also a non-stock "headers more" module that can set
headers. Depending on your requirements, that may be interesting to you.)

Francis Daly        francis at daoine.org

More information about the nginx mailing list