Nginx Configuration for websocket: Error during WebSocket handshake: Unexpected response code: 403

Sergey Kandaurov pluknet at nginx.com
Thu Jun 10 12:00:36 UTC 2021


> On 10 Jun 2021, at 13:14, raphy <nginx-forum at forum.nginx.org> wrote:
> 
> In order to use XMPP with websocket, and take advantage of nginx
> capabilities to proxy to 443 and to serve multiple domains, I've configured
> nginx as follows:
> 
> 
>    server {
>        listen 443 ssl http2 default_server;
>        server_name grasp.deals www.grasp.deals;
>        ssl_certificate /etc/letsencrypt/live/grasp.deals/fullchain.pem; #
> managed by Certbot
>        ssl_certificate_key /etc/letsencrypt/live/grasp.deals/privkey.pem; #
> managed by Certbot
>        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
>  
[..]
>    }
> 
> In the app I'm developing, when I switch from BOSH (http-bind), which works
> fine:
> 
>    let [conn, setConn] = React.useState(new
> Strophe.Connection("https://grasp.deals/http-bind"));
> 
> to websocket:
> 
>    let [conn, setConn] = React.useState(new
> Strophe.Connection("wss://grasp.deals/xmpp-websocket"));
> 
> I get this error:
> 
>    WebSocket connection to 'wss://grasp.deals/xmpp-websocket' failed: Error
> during WebSocket handshake: 
>    Unexpected response code: 403

nginx doesn't support bootstrapping WebSockets with HTTP/2.

-- 
Sergey Kandaurov



More information about the nginx mailing list