0

I've started working with the Flask framework recently side-by-side with Node.js and have never heard of setting up a proxy server for a Node.js application. So I was wondering why is it necessary to use Nginx as a proxy server for a Flask application?

Also, what would be the best way to deploy a Flask app to the production?

This question Are a WSGI server and HTTP server required to serve a Flask app? gives me some idea on purpose of WSGI server and HTTP server.

I also had confusion on whether I can use a proxy server for the Node.js application or not.

Please someone help me on this.

Subbu
  • 663
  • 1
  • 9
  • 20
  • [An answer to the same question is on ServerFault](https://serverfault.com/q/331256/398223). You can apply the same principle to Django and Flask, they both work the same regarding WSGI protocol and communication with a reverse proxy (Nginx or any other). The real question for me is : Why node.js application doesn't need a reverse proxy to serve an application securely? – Antwane Oct 26 '18 at 09:56

1 Answers1

3

NGINX is a HTTP server that is used in lots of different application stacks. It performs a lot of functions, but it is not able to directly interface with a Flask application.

That is where Gunicorn comes in to play. HTTP requests are received by NGINX and passed along to Gunicorn to be processed by your Flask application (think of the route(s) defined in your views.py).

Gunicorn is a WSGI server that handles HTTP requests and routes them to any python application that is WSGI-compliant, such as Flask, Django, Pyramid, etc.

For Detailed Description

stillfool
  • 443
  • 2
  • 9
  • Thanks a lot. What do you think about proxy server set up for nodejs application? – Subbu Oct 26 '18 at 10:45
  • Nginx are often used between the internet and applications as reverse proxies redirecting requests to different machines or ports. They can also be used to cache pages to provide them quicker than a service that would calculate the page every time requested. So in answer they should not be necessary but may be useful. – stillfool Oct 26 '18 at 11:02