The title centos nginx configures both ipv4 and ipv6 addresses to access the same website
It is relatively simple to configure in Nginx that both IPv4 and IPv6 addresses can access the same website. Just make sure that the Nginx configuration file is properly configured with listeners for both IPv4 and IPv6 addresses.
- Open your Nginx configuration file, usually located in the
/etc/nginx/nginx.conf
or/etc/nginx/conf.d/
directory. - Edit the configuration file and add the following to configure listeners
IPv4
andIPv6
addresses:
server {
listen 80; # 监听IPv4地址的80端口
listen [::]:80 ipv6only=on; # 监听IPv6地址的80端口
server_name example.com; # 设置你的域名
location / {
# 配置其他的网站设置,比如代理、反向代理等
}
}
In the example above, listen 80
the ; part means listen IPv4 地址的 80 端口
while the listen [::]:80 ipv6only=on
; part means listen IPv6 地址的 80 端口
and enable the ipv6only option.