Skip to content

"map" directive is not allowed here in /etc/nginx/nginx.conf

I'm in the process of creating a new server. I'm using the SDTP image from approximately 1Dec2021. When I try to start for the first time, I'm seeing the following in my nginx startup... note the "map" directive error in the first line:

nginx_1     | 2021/12/07 16:18:14 [emerg] 1#1: "map" directive is not allowed here in /etc/nginx/nginx.conf:1
nginx_1     | nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:1
nginx_1     | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1     | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1     | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
nginx_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx_1     | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1     | 2021/12/07 16:19:06 [emerg] 1#1: "map" directive is not allowed here in /etc/nginx/nginx.conf:1
nginx_1     | nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:1

I'm using the default nginx.conf file that comes with the docker_deploy downloaded via git:

map $ssl_client_verify $cert_uid {
  default "";
  SUCCESS $ssl_client_s_dn;
}

server {
    listen      80 default_server;
    listen [::]:80 default_server;
    server_name _;

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen      443 ssl;
    listen [::]:443 ssl;

    ssl_certificate        /path/to/chain.pem;
    ssl_certificiate_key   /path/to/priKey.pem;
    ssl_client_certificate /path/to/trustedCA.pem;
    ssl_verify_client      optional;

    location / {
        proxy_set_header Cert-UID "$cert_uid";
        proxy_pass http://localhost:8080;
    }
}

The map directive in theory should be in an http block. Am I missing something? Thanks Paul

Edited by Navid Golpayegani