nginx配置支持ipv6访问
前提,需要nginx支持ipv6模块
现在的新版本都支持,以下在nginx-1.9.12本版测试可用!
非常简单,只需要在*.conf文件中配置同时支持v4 和v6,添加以下两行命令即可
listen 80;
listen [::]:80;
[root@localhost conf.d]# cat nginx.conf
server {
listen 80;
listen [::]:80;
server_name www.test.cn;
root /test/html/;
index index.html index.htm;
location / {
proxy_pass http://127.0.0.1:19999;
}
location /downloads/ {
alias /root/app/downloads/;
}
}
server {
listen 80;
server_name api.test.cn;
location / {
proxy_pass http://127.0.0.1:19999;
}
location /downloads/ {
alias /root/app/downloads/;
}
}