Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
Apache2 + Socket.io reverse proxy : the right way to proceed

this is not a question but a great help difficult to find on the internet,

to correctly configure socket.io with apache2 through websocket requests and not polling requests, here is how to proceed:

First : create your socket.io server like const io = require('socket.io')(yourPort)

Second : add in your favorite vHost these parameters

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteRule /(.*)           ws://localhost:yourPort/$1 [P,L]

ProxyPass        /socket.io http://localhost:yourPort/socket.io
ProxyPassReverse /socket.io http://localhost:yourPort/socket.io

(modify yourPort by the correct port where your server listen)

Third : Create your HTML page with

let socket = io.connect('yourWebsite', { transports: ['websocket'] });

Now if you want you can add this in your server for check if it's work

io.on("connection", socket => {
  console.log("it's work !")
})

100% working do not thank me :) Have a nice day.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda