I am trying to use the Flask application on uwsgi / nginx.
This http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html as well as http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ , I could make a file wiki.ini ,
[uwsgi] vhost = true socket = /tmp/flask_app.sock venv = /home/ubuntu/webapp/flask/hello/.env chdir = /home/ubuntu/webapp/flask/hello module = flaskapp callable = app chmod-socket = 666
I checked that the wiki.ini file wiki.ini fine with uwsgi --ini wiki.ini .
Then I tried to run the Flask application at boot time.
In sudo update-rc.d uwsgi enable I can start the uwsgi service at boot time and copy the wiki.ini file to the /etc/uwsgi/apps-enabled directory.
This is the conf file for nginx.
server { listen 80; server_name wiki.example.com; access_log /var/log/nginx/uwsgi_access.log; error_log /var/log/nginx/uwsgi_error.log; location / { try_files $uri @riki; } location @riki { include uwsgi_params; uwsgi_pass unix:/tmp/flask_app.sock; } error_page 404 /404.html; }
However, when I rebooted my ubuntu server, the Flask application does not work. I checked the error log to find this error message.
2015/11/07 17:48:17 [crit] 1055
I created the file /tmp/flask_app.sock and ran chown -R www-data:www-data /tmp/flask_app.sock to make the application work.
> touch /tmp/flask_app.sock > sudo chown www-data:www-data /tmp/flask_app.sock > sudo service uwsgi restart > sudo service nginx restart
However, I had another connection failure error.
2015/11/07 17:50:38 [error] 1055#0: *4 connect() to unix:/tmp/flask_app.sock failed (111: Connection refused) while connecting to upstream, client: 68.203.30.28, server: wiki.example.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/tmp/flask_app.sock:", host: "wiki.example.com"
What could be wrong? How to teach uwsgi to create a unix domain socket? Also, how to make the connection work? I am using ubuntu 14.04.
EDIT
Removing /tmp/flask_app.sock and running uwsgi --ini /etc/uwsgi/apps-enabled/wiki.ini makes the application work fine.