Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use gunicorn with a reverse-proxy?

From Gunicorn's documentation:

Deploying Gunicorn

We strongly recommend to use Gunicorn behind a proxy server.

Nginx Configuration

Although there are many HTTP proxies available, we strongly advise that you use Nginx. If you choose another proxy server you need to make sure that it buffers slow clients when you use default Gunicorn workers. Without this buffering Gunicorn will be easily susceptible to denial-of-service attacks. You can use slowloris to check if your proxy is behaving properly.

Why is it strongly recommended to use a proxy server, and how would the buffering prevent DOS attacks?

like image 478
confused00 Avatar asked Nov 11 '14 09:11

confused00


1 Answers

According to the Nginx documentation, a reverse proxy can be used to provide load balancing, provide web acceleration through caching or compressing inbound and outbound data, and provide an extra layer of security by intercepting requests headed for back-end servers.

Gunicorn is designed to be an application server that sits behind a reverse proxy server that handles load balancing, caching, and preventing direct access to internal resources.

By exposing Gunicorn's synchronous workers directly to the internet, a DOS attack could be performed by creating a load that trickles data to the servers, like the Slowloris.

like image 153
cjohnson318 Avatar answered Sep 20 '22 19:09

cjohnson318