Redirects in Nginx

We at tekduke just love nginx so much. Generally, it is our default web server. Although we use traefik for some parts of our infrastructure, mostly we are running the open source nginx on our production servers as a reverse proxy or web-server. It comes in handy to know how to handle redirects. Redirects can be used for a variety of operations including HTTP to HTTPS, non-www to www, Moving from to etc. redirect is such a humble yet powerful tool when it comes to SEO as well. let's take a look at the most common redirect examples in nginx:

This is a companion discussion topic for the original entry at