I have been following the tutorial here to deploy my own flask app to my Ubuntu 16 server. I used Nginx
as a reverse proxy to pass requests to a gunicorn
socket. Just in case anyone wants to know ufw
is allowed for Nginx All
.
Here is what I tried so far:
- I checked if the
Flask
app ran on the local server by running the application locally on port5000
(worked fine) - I checked if gunicorn was able to serve by running :
gunicorn --bind 0.0.0.0:5000 wsgi:app
(worked fine) - I made the
/etc/systemd/system/myapp_service.service
file (below)
[Unit]
Description=Gunicorn instance to serve my app
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/var/www/app/flaskapp
Environment="PATH=/home/ubuntu/.virtualenvs/app_env/bin"
ExecStart=/home/ubuntu/.virtualenvs/app_env/bin/gunicorn --workers 3 --bind unix
:/var/www/app/flaskapp/myapp.sock -m 002 wsgi:app
[Install]
WantedBy=multi-user.target
- I made an
Nginx
configuration file insites-available
as below:
server {
listen 80;
server_name app.mydomain.com;
location / {
include proxy_params;
proxy_pass http://unix:/var/www/app/flaskapp/myapp.sock;
}
}
- I made a symbolic link to
sites-enabled
, ransudo nginx -t
- Restarted
Nginx
andmyapp_service
withsystemctl
- When I go to
http://app.mydomain.com
it just shows me that big "Welcome to Nginx" page instead of my app.
What more do I need to configure?