Nginx: 开启Ipv6
1. 在Ubuntu上安装Nginx
将以下源加入/etc/apt/sources.list:
deb http://nginx.org/packages/ubuntu/ lucid nginx deb-src http://nginx.org/packages/ubuntu/ lucid nginx
然后用apt-get
进行安装:
apt-get install nginx
安装时如果出现如下警告可以不必理会:
WARNING: The following packages cannot be authenticated!
2. 检查是否支持IPv6
首先我们检查系统是否有IPv6接口:
ifconfig eth0
如果有这样一行(注意粗体部分):
inet6 addr: 2400::89b3/64 Scope:Global
则说明你的主机有直接的IPv6公网地址。接下来检查Nginx是否有IPv6模块(默认已编译):
nginx -V
如果看到–with-ipv6编译选项,则表示可以继续。
3. 开启Ipv6
编辑/etc/nginx/conf.d/default.conf
如果想要同时监听IPv4和IPv6,则只需要这样配置:
listen [::]:80;
或者可以明确一些:
listen [::]:80 ipv6only=on; # listen for IPv6 only traffic on IPv6 sockets listen 80; # listen also for IPv4 traffic on "regular" IPv4 sockets
如果只想监听IPv6,则只需要:
listen [::]:80 ipv6only=on;
配置完后重启Nginx服务:
# /etc/init.d/nginx restart * Restarting nginx nginx [ OK ]
References:
[1] Official Debian/Ubuntu packages
[2] Enable IPv6 in Nginx
[3] HttpCoreModule 2.31 listen