Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
Authenticating websocket requests with nginx

There is a WebSocket server that I can't modify, and I don't want everyone to send requests to this. I want to add something like HTTP basic auth to the WebSocket so that it doesn't allow every request to pass through to the actual server. I am using Nginx and want to stick to it, but if there is any other program that accomplishes this, I am ok with that too.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Thanks to Lawrence, I checked out the docs for subrequest and this works now, after writing an auth server with node.js

server {
    location /ws {
        auth_request /auth;
        auth_request_set $auth_status $upstream_status;

        proxy_pass http://localhost:1234;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    location /auth {
        internal;
        proxy_pass http://localhost:3003;
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";
        proxy_set_header X-Original-URI $request_uri;
        proxy_set_header X-Original-Remote-Addr $remote_addr;
        proxy_set_header X-Original-Host $host;
    }
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda