Nginx is a web server and puma is an application server.
Both have their advantages, and you need both.
Some examples:
-
Static redirects- you could setup your nginx to redirect all
http
traffic to the same url withhttps
. This way such trivial requests will never hit your app server. -
Multipart upload- Nginx is better suited to handle multipart uploads. Nginx will combine all the requests and send it as a single file to puma.
-
Serving static assets- It is recommended to serve static assets (those in
/public/
endpoint in rails) via a webserver without loading your app server. -
There are some basic DDoS protections built-in in nginx.