nginx – host not found in “$server_listen_port” of the “listen” directive
With the following nginx config excerpt:
map $server_name $server_listen_port {
default 443;
localhost. 80;
localhost 80;
}
server {
server_name "${ENVIRONMENT_SERVER_NAME}.";
listen $server_listen_port http2 reuseport;
# ...
}
I get the following error when validating the configuration with ENVIRONMENT_SERVER_NAME set in the environment to “localhost”:
nginx: [emerg] host not found in "$server_listen_port" of the "listen" directive in /etc/nginx/conf.d/99_main.conf:38
nginx: configuration file /etc/nginx/nginx.conf test failed
I am trying to decipher what this error message means exactly. Does it mean that the listen statement is invalid because it is missing a hostname?
Or is it perhaps trying to tell me there is no value in the map for the host? I would expect the “default” to be invoked in that case.
I have tried all manner of variations without really getting anywhere.
What is causing this error, and how can I fix it?
Read more here: Source link