查看nginx是否支持ipv6
# /usr/local/nginx-1.7.0/sbin/nginx -V nginx version: nginx/1.7.0 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: --prefix=/usr/local/nginx-1.7.0 --with-http_stub_status_module
没有出现–with-ipv6,说明当前的nginx不支持ipv6,所以我们需要重新编译nginx,配置里面增加–with-ipv6,具体怎么安装,我不在啰嗦了。
同时监听IPV4和IPV6
server { .... listen [::]:80; ... }
只监听IPV6
server { .... listen [::]:80 default ipv6only=on; ... }
监听指定IPV6地址
server { .... listen [3608:f0f0:3002:31::1]:80; ... }
重启nginx
/usr/local/nginx-1.7.0/sbin/nginx -s reload
转载请注明:爱开源 » nginx开启IPV6支持配置