Ngnix not forwarding request to gunicorn socket.

September 11, 2019 85 views
Python Frameworks Nginx Python

I’ve was following This article of digital ocean https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

I was able to setup flask, gunicorn, Nginx correctly but any request to my server Nginx routes to default Nginx home page rather forwarding to my app. It’s been three days since I am debugging this but not able to solve this.

Some difference between my setup vs this article mentions is,

  1. Instead of server name I’ve used my server public gateway address
  2. I am using Centos 7 rather ubuntu 18.04
    3 I am using group 1000 instead of www-data.

rest is same. Its not showing any error also so I am not sure what is happening, any help is welcomed

1 Answer

Hi :)

First off, good job on getting this far. Just FYI, many of the more popular tutorials have versions for different platforms, eg, there is a version of that tutorial for Centos 7 here:

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7

OK, so in the nginx config, for server_name you put your public Droplet IP? That’s in this section of the tutorial, https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7#configuring-nginx-to-proxy-requests.

At the end of that section there’s a couple of commands to start and enable this config - were you able to run those? If nginx is already running, you may need to restart it like:

sudo systemctl restart nginx

Hope this helps, let us know how it goes.

by Justin Ellingwood
In this guide, we will be setting up a simple Python application using the Flask micro-framework on CentOS 7. The bulk of this article will be about how to set up the Gunicorn application server to launch the application and Nginx to act as a front end reverse proxy.
Have another answer? Share your knowledge.