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

730
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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