0

Have problem with secured websocket connection. I have app running on https, where mutations and queries works, but cannot establish wss connection :/ When I run the react app on not secured connection (http) and use ws then all is ok. I am not sure what may cause this issue - maybe nginx proxy, maybe nestjs graphql config or maybe react apollo client. Shortly:

Have server with nginx with configured cert. The server proxy subdirectory of my domain to some app (runned in docker container and exposed on port 3000):

server { listen 443 ssl; server_name mydomain.com [...cert configs...] location /one/of/app/ { proxy_pass http://localhost:3000/ } } 

As I mentioned the website works with secured connection, but the wss connection failed. I do not do anything extra in server or client - all configuration all the same instead the uri (https, wss instead http, ws). On not secured connection, with ws:// websocket works. Any sugestions?

Full error:

WebSocket connection to 'wss://mydomain.com/one/of/app/graphql' failed: Error during WebSocket handshake: Unexpected response code: 400 
0

1 Answer 1

0

Found solution here: https://stackoverflow.com/a/48096141/13514288

Added for api (/one/of/app/) nginx proxy extra headers:

location /one/of/app/ { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://localhost:3000/ } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.