Rupert
Rupert

Reputation: 4347

Flask using Nginx?

I am a .net developer coming over to python. I have recently started using Flask and have some quick questions about serving files.

I noticed a lot of tutorials focused on nginix and flask. However, I am able to run flask without nginx. I'm just curious as to why this is used together (nginx and flask). Is nginx only for static files?

Upvotes: 2

Views: 231

Answers (3)

Tohmaxxx
Tohmaxxx

Reputation: 434

From http://flask.pocoo.org/docs/1.0/deploying/ :

"While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well. Some of the options available for properly running Flask in production are documented here."

Upvotes: 0

Anuvrat Parashar
Anuvrat Parashar

Reputation: 3100

On a development machine flask can be run without a webserver (nginx, apache etc) or an application container (eg uwsgi, gunicorn etc).

Things are different when you want to handle the load on a production server. For starters python is relatively very slow when it comes to serving static content where as apache / nginx do that very well.

When the application becomes big enough to be broken into multiple separate services or has to be horizontally scaled, the proxy server capabilities of nginx come in very handy.

In the architectures I build, nginx serves as the entry point where ssl is terminates and the rest of the application is behind a VPN and firewall.

Does this help?

Upvotes: 1

Gerardo Rochín
Gerardo Rochín

Reputation: 309

Nginx is a proxy server, imagine your apps have multiples microservices on differents languagues.

For more info NGINX REVERSE PROXY

Upvotes: 1

Related Questions