Report this

What is the reason for this report?

Flask+nginx+uwsgi+Ubuntu tutorial

Posted on May 3, 2017

My hopes are lost and so is my temper. I have followed the tutorial found here - https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04

I have reinstalled and started all over 10 times and still same PROBLEM. Is there another tutorial available because this only works to 80%. All works fine up to a certain point but I always get a 502 gateway problem.

I created a new user belonging to sudo group. Ssh:ed to server with this new user – all good. Set up domain also and if I ping domainname.com the correct droplet ip gives reply – all good.

python myproject.py (to start flask) works perfect

uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app

Works perfect and site is accessible with IP http://server_IP:5000

Content of wsgi.py-

from myproject import app

if name == “_main”: app.run()

Content of myproject.ini looks like -

[uwsgi]

module = wsgi:app

master = true processes = 5

socket = myproject.sock chmod-socket = 660 vacuum = true

die-on-term = true

Content of /etc/systemd/system/myproject.service:

[Unit] Description=uWSGI instance to serve myproject After=network.target

[Service] User = blizzard Group = www-data WorkingDirectory = /home/blizzard/myproject Environment = “PATH=/home/blizzard/myproject/myprojectenv/bin” #IS THIS LINE WRONG?? ExecStart=/home/blizzard/myprojectenv/bin/uwsgi --ini myproject.ini

[Install] WantedBy = multi-user.target

Content of /etc/nginx/available-sites/myproject

server { listen 80; server_name billigaflygtilllondon.com www.billigaflygtilllondon.com;

    location / {
    include uwsgi_params;
    uwsgi_pass unix:///home/blizzard/myproject/myproject.sock;
    }

}

If this tutorial is wrong why dont staff delete it or at least the author updates it since I am not the ONLY ONE having problems. If there is a helpful soul who could guide me I would be more than happy.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.