1

I have a page that has a .../chat/ url, and the whole thing works on localhost. I'm trying to deploy on ubuntu and having a hard time.

I guess getting to the point looks like posting what I've got:

/etc/nginx/sites-enabled/mysite:

limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;

upstream channels-backend {
    server localhost:8001;
}

server {
    listen 80;
    server_name foo.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ubuntu/mysite/mysite/;
    }

    location / {
        include proxy_params;
        limit_req zone=mylimit;
        proxy_pass http://unix:/run/gunicorn.sock;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

I tried changing my server block to contain:

...
    location / {
        try_files $uri @proxy_to_app;
        include proxy_params;
        limit_req zone=mylimit;
        proxy_pass http://unix:/run/gunicorn.sock;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location @proxy_to_app {
        proxy_pass http://channels-backend;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }
...

but this prompted my webpage to 503.

My python and js seem fine as it works on localhost, and running daphne -b 0.0.0.0 -p 8001 myproject.asgi:application results in a Listening... message so that seems fine.

My /etc/supervisor/conf.d/mysite.conf is:

[program:mysite_asgi]
directory=/home/ubuntu/mysite/mysite
command=/home/ubuntu/mysite/mysite/venv/bin/daphne -b 0.0.0.0 -p 8001 mysite.asgi:application
autostart=true
autorestart=true
stopasgroup=true
user=ubuntu
stdout_logfile=/home/ubuntu/mysite/daphnelog/asgi.log
redirect_stderr=true

The browser console shows WebSocket connection to 'ws://foo.com/chat/' failed: Error during WebSocket handshake: Unexpected response code: 503, I'm unsure if I've posted a complete picture of what needs to be said in order to help you help me--please let me know if there's more information to reach that end. Thank you!

ILoveCliques
  • 135
  • 1
  • 11

0 Answers0