Using the return directive, clients can easily be returned a HTTP code and an optional URL. For example, if you’re redirect all HTTP traffic to HTTPS or www to non-www, returning 301 Moved Permanently is appropriate.
Nginx Proxy and Upstream Modules
Nginx continues to gain market share and is probably the most viable open-source HTTP server currently competing against Apache today. With its asynchronous, event-driven architecture, Nginx is able to scale extremely well and can outperform Apache under heavy loads. Couple this with its support for proxying WebSocket protocol, and you’ve got a solid choice for a reverse proxy or load balancer.