Running Flask application without nginx Running Flask application without nginx nginx nginx

Running Flask application without nginx


For running flask, you do not need nginx, just a webserver of your choice, but life with nginx is just easier. If you are using Apache, you want to consider to use a WSGI.

I remember reading somewhere in the Flask documentation what is stated by an answer to "Are a WSGI server and HTTP server required to serve a Flask app?" as

The answer is similar for "should I use a web server". WSGI servers happen to have HTTP servers but they will not be as good as a dedicated production HTTP server (Nginx, Apache, etc.).

The main idea behind is the architectural principle of splitting layers to ease debugging and increase security, similarly to the concept that you split content and structure (HTML & CSS, UI vs. API):

  • For the lower layers, see e.g. https://en.wikipedia.org/wiki/Transport_layer Having a dedicated HTTP server allows you to do package-filtering etc. on that level.
  • The WSGI is the interface layer between the webserver and the webframework.

Update

I have seen clients only running a WSGI server alone, with integrated HTTP support. Using an additional webserver and/ or proxy is just good practice, but IMHO not strictly necessary.

References