Nginx: redirect HTTP request to tcp?

I currently have the following setup:

  • nginx: port 80, acts as a web server and proxy
  • nodejs: port 8888 launched by socket.io (which uses web files)

So, I tried using the latest development branch for nginx, but does not support websocket.

I gave tcp_proxy a try and it works fine. (Although I tried it with a different port for the connection, and it did not enable this URL-based reverse proxy)

My problem right now is that I cannot route HTTP requests that start with /socket.io to tcp_proxy.

tcp { upstream nodejs { server 127.0.0.1:8888; } } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; tcp_nopush on; tcp_nodelay off; server { listen 80; server_name www.mysite.com; root someroot; location /socket.io { # How do I redirect to upstream nodejs? } } } 

Thanks for the help!

+2
source share

Source: https://habr.com/ru/post/1403792/


All Articles