I
I
Igor2016-12-08 12:53:06
Python
Igor, 2016-12-08 12:53:06

How to deploy aiohttp chat (Nginx+Supervisord)?

Hey!
There is an Ubuntu 16.04.1 LTS server (GNU/Linux 4.4.0-53-generic x86_64)
I decided to deploy aiohttp following the documentation example. Only in a more simplified form.
My nginx config:

upstream aiohttp_chat {
    server 127.0.0.1:8080;
}

server {

    listen 80;
    server_name example.com;

    error_log /var/log/nginx/error.log;

    location / {

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_pass http://aiohttp_chat;

        proxy_read_timeout 200;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Supervisor config:
[program:chat]
command=/home/ubuntu/www/venv/bin/python /home/ubuntu/www/aiohttp-chat/app.py
directory=/home/ubuntu/www/aiohttp-chat
user=nobody
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/chat.err.log
stdout_logfile=/var/log/supervisor/chat.out.log

aiohttp router:
router = app.router
router.add_route('GET', '/chat/{channel}/{token}/', handlers.websocket_handler)

I run:
loop = asyncio.get_event_loop()
app = loop.run_until_complete(get_app())
web.run_app(app)

When trying to connect (ws://example.com/chat/1/dsfbgrgbre432t325q/) via any online websocket client or chrome extension, I get an undefined error.
It is not clear what exactly does not work - nginx error.log is empty, access.log shows that someone is trying to reach out, but attempts end in 404.
Supervisord is working properly - status RUNNING.
Do I need to write the regex of my router in Nginx in the location block?
Tell me, what is my problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2016-12-08
@IgorPosmashny

The problem was solved by opening port 8080.

V
Vladimir, 2016-12-08
@vintello

ws://example.com/chat/1/dsfbgrgbre432t325q/
why on example.com?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question