0

There are a lot of clear answers to the question on why one should use Nginx in a classic 3-tier architecture with a Gunicorn/Flask app where you also serve static content.

The architecture I want to deploy is different and I can't find an answer to my doubt if it would make sense to put Nginx in front of Gunicorn in this case.

In my case I have I typical back-end in Node.js but when new data is sent to the back-end it sends this for asynchronous processing to a Gunicorn/Flask app.

The Node app and the Gunicorn/Flask app are in two different Docker containers and communicate over a docker network. Only the Node app communicates with the Gunicorn/Flask app.

Does it make sense in any way to put Nginx in front of the Gunicorn/Flask app as it does not serve static content and is not connected to the "outside world"?

Thank you!

Edit:

I add new information based on Michael Hampton's comment:

There is also a front-end component which is served by Nginx. Incoming traffik gets redirected by traefik to the front-end component or the Node back-end component for which I use pm2.

There are two docker networks. On one hand a network that is used for traefik where, apart from traefik, the front-end and the Node back-end component are attached to as they have to be accessible from the outside. On the other hand, there is an internal network where the Node back-end component and the Gunicorn/Flask app are attached to in order to make sure the Gunicorn/Flask app is not accessible from the outside.

At the moment the Node back-end component sends requests directly over the internal docker network to the Flask app via the port on which Gunicorn is serving it. As I don't want it to be accessible from outside, traffic to Gunicorn does not get redirected through traefik.

Is this a good approach or should I put something like Nginx in front of Gunicorn in the Gunicorn/Flask container?

Bastian
  • 1
  • 1
  • No, in this case you would have nginx in front of both of them. – Michael Hampton Nov 15 '18 at 18:12
  • What do you mean with 'in front of both of them'? Although I do not need reverse proxying and the Gunicorn/Flask app should not be accessible from the internet would you put Nginx in front of it? Thank you! – Bastian Nov 17 '18 at 16:19
  • I mean that nginx will reverse proxy to both the Node server app and the Flask app. Remember that Gunicorn is only a bare bones web server meant to serve your Flask app; if you need _anything_ else, like access control etc., then you need a web server in front of it. And even if you don't, a web server will speed up serving static content, which you are sure to have at least some of. Of course, it does sound like your existing setup is probably a bit overly complicated... – Michael Hampton Nov 18 '18 at 01:59
  • As I mentioned the processing part does not serve any static content and there is no need for reverse proxy because it is not meant to be accessible from the internet. Would you still put Nginx in front of it? – Bastian Nov 22 '18 at 08:50

0 Answers0