S
S
Sergey Vasiliev2022-02-05 15:48:57
Nginx
Sergey Vasiliev, 2022-02-05 15:48:57

How to proxy a web socket?

Hello. I developed a project in WebStorm and decided, for convenience, to proxy it to my web server via nginx (so that the front and back are in the same domain).
After proxying, an error appeared:

WebSocketClient.js:16 WebSocket connection to ' wss://testsite.domain.ru:3000/ws ' failed:

as I understand it, this is because the websocket in node_modules connects to the localhost IP, which, when proxying, is not my local computer, but a remote site.

How can I proxy this websocket through Nginx so that all requests are redirected to my computer? Accordingly, just like the site itself, strem and the usual proxying of the site did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2022-02-05
@q2digger

First, show the code from the nginx config related to the location you forwarded.
Dock on the nginx website - https://www.nginx.com/blog/websocket-nginx/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question