0

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:

  1. I checked if the Flask app ran on the local server by running the application locally on port 5000 (worked fine)
  2. I checked if gunicorn was able to serve by running : gunicorn --bind 0.0.0.0:5000 wsgi:app (worked fine)
  3. 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
  1. I made an Nginx configuration file in sites-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;
    }
}
  1. I made a symbolic link to sites-enabled, ran sudo nginx -t
  2. Restarted Nginx and myapp_service with systemctl
  3. 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?

wellwellwell
  • 63
  • 1
  • 8

1 Answers1

0

probably this one is wrong:

proxy_pass http://unix:/var/www/app/flaskapp/myapp.sock;

Try to leave only this part:

proxy_pass unix:/var/www/app/flaskapp/myapp.sock;

Viktor
  • 221
  • 2
  • 2
  • No the way I wrote is what is correct, according to `nginx`. If I remove http:// the `sudo nginx -t` syntax check fails – wellwellwell Feb 03 '20 at 16:34