What is the purpose of using nginx with gunicorn? [duplicate] What is the purpose of using nginx with gunicorn? [duplicate] nginx nginx

What is the purpose of using nginx with gunicorn? [duplicate]


Nginx has some web server functionality (e.g., serving static pages; SSL handling) that gunicorn does not, whereas gunicorn implements WSGI (which nginx does not).

... Wait, why do we need two servers? Think of Gunicorn as theapplication web server that will be running behind nginx – the front-facing web server. Gunicorn is WSGI-compatible. It can talk to otherapplications that support WSGI, like Flask or Django.

Source: https://realpython.com/blog/python/kickstarting-flask-on-ubuntu-setup-and-deployment/


Nginx is a reverse proxy for Gunicorn. Gunicorn serves your Flask app and Nginx sits in front of it and decides where a request should go. For example, if the incoming request is an http request Nginx redirects it to gunicorn, if it is for a static file, it serves it itself. Read more about how to use Nginx and Gunicorn and how to deploy them starting from here.


Gunicorn is an application server for running your python application instance.

NGINX is a reverse proxy. It accepts incoming connections and decides where they should go next. It is in front of Gunicorn.