0

I am trying to serve a flask application using nginx and uwsgi, through an ubuntu docker container, while the host is also an ubuntu 18.04 OS.

This is the conf file for the nginx server, for which I have created a symbolic link in /etc/nginx/sites-enabled:

server {
    listen 1611;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.1;
    server_name localhost;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/step_service/socket.sock;
        uwsgi_modifier1 30;    
    }
}

The `uwsgi.ini' file is as follows:

[uwsgi]
base=/var/www/html/step_service
app=app
module=%(app)
callable = app

home=%(base)/venv
pythonpath=%(base)
socket=%(base)/socket.sock
chmod-socket=777

master=true
processes=5
threads=5
die-on-term=true
autostart=true
autorestart=true
harakiri=30
logto=/var/www/html/step_service/log/%n.log

The logs of uwsgi seem to indicate success:

 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

The logs of nginx server (in particular error.log) is:

2019/04/18 16:23:30 [error] 6729#6729: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.17.0.1, server: localhost, request: "GET /rec/1/1 HTTP/1.1
", upstream: "uwsgi://unix:/var/www/html/step_service/socket.sock", host: "172.17.0.2:1611"

Any ideas would be more than welcome!

  • 1
    Did you use the right uwsgi.ini? Your app is listening on TCP port 5000, not on the Unix socket specified. You should also heed the warning about using a production uwsgi server. And the nginx server on port 1611 is utterly redundant. Just have your uwsgi server listen on that port if you want it there. – Michael Hampton Apr 18 '19 at 16:59
  • The warning comes from Flask, and that's why I'm using wsgi with nginx. But how should I specify a socket that listens to port 5000? – Dimitris Poulopoulos Apr 18 '19 at 17:27
  • https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html It's the very first example... – Michael Hampton Apr 18 '19 at 17:30

0 Answers0