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

726
Vistas
How to proxy both WSGI and ASGI via Uvicorn or Daphne with nginx and SSL proxy?

I have a small project that uses Django Channels (websockets) and it works fine locally. I've added SSL to my docker-based deployment with the letsencrypt-companion-container docker image, which, exposes 443, handles all the SSL, then funnels requests/responses vi port 80 into my A/WSGI adapter (uvicorn or daphne).

When under SSL, my client code is getting this error in the JS console:

`WebSocket connection to 'wss://my_server.com/ws/echo/' failed: Error during WebSocket handshake: Unexpected response code: 404`

It isn't clear to me why. How do I make this work?

Here is my nginx.conf, if it helps:

upstream wsgi {
    server web:8000;
}

upstream asgi {
    server web:8000;
}

server {
    listen 0.0.0.0:80;

    location / {
        proxy_pass http://wsgi;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }

    location /ws {
        proxy_pass ​http://asgi;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
    }

    location /staticfiles/ {
        alias /home/app/web/staticfiles/;
    }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I was facing a similar issue, I got a 403 error on my django server. After checking this and setting my ALLOWED_HOSTS = "*" the server worked.

Being honest it doesn't look like a best practice to me, but while I find something better, is a way to have the server up and running.

Make sure also that you include this configuration on your nginx

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