Introduction
Sometimes you want to change or assign values based on other values in your web server. The map directive in nginx helps you create new variables by matching existing ones to new values. This makes your server smarter and more flexible without complex code.
When you want to set different backend servers based on the requested domain name.
When you need to assign custom headers depending on the user agent of the visitor.
When you want to enable or disable features based on the client IP address.
When you want to rewrite URLs differently depending on the request path.
When you want to simplify complex if-else logic by mapping values in one place.