Configuring the mapping

Configuring the mapping

The ngx_http_map_module module creates variables which values depend on values of other source variables specified in the first parameter.

Syntax map string $variable { ... }
Default
Context HTTP
NGINX configuration sample
map $my_geo_map_variable $ip_limit_action {
    default "";
    1 $binary_remote_addr;
    0 "";
}

Example of a Salt pillar for the map module:

nginx:
  server:
    map:
      enabled: true
      items:
        global_geo_limiting_map:
          enabled: true
          string: my_geo_map_variable
          variable: ip_limit_action
          body:
            default:
              value: '""'
            limited:
              name: '1'
              value: '$binary_remote_addr'
            unlimited:
              name: '0'
              value: '""'

All map variables specified in the pillars, after applying the nginx.server state, will be reflected in the /etc/nginx/conf.d/map.conf file.