I am currently configuring a software to be able to handle IPv6 addresses, I have also configure the Nginx docker image so that it can handle both IPv4 and IPv6 address. The problem that I encounter is that I am not sure if the host machine where the software is going to be deployed has IPv6 enabled or not.
The issue is that whenever the IPv6 is not enabled in the host machine it is causing the error below.
nginx: [emerg] socket() [::]:8080 failed (97: Address family not supported by protocol)
2018/01/23 10:53:08 [emerg] 1#1: socket() [::]:8080 failed (97: Address family not supported by protocol)
What I am trying to achieve is that even if the host machine is not IPv6 enabled, the nginx would ignore all IPv6 and simply go to the IPv4. One solution I found is by using the environment variable (envsubsts) that is discussed in the nginx docker repository and use the docker-compose file to set the port and address. However this solution will need a manual changes in docker-compose file depending if IPv6 is enabled or not.
Any help or suggestion will do. THANKS!
Here is the part of my nginx configuration that handles IPv6 and IPv4.
server {
listen [::]:8080 ssl ipv6only=off;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/key.pem;
...
...
}
}
I have also tried separating the IPv4 and IPv6 but it is still causing the issue.
listen 8080 ssl;
listen [::]:8080 ssl ipv6only=on;