nginx開啟IPV6支援配置
IPV4日益稀缺,ipv6已經慢慢走上日程,待ipv6在國內普及,使用nginx配置ipv6那是肯定的,看看如何讓nginx支援ipv6以及配置.
檢視nginx是否支援ipv6
1234 | # /usr/local/nginx-1.7.0/sbin/nginx -Vnginx version:nginx/1.7.0built by gcc4.4.720120313(Red Hat4.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
1 2 3 4 5 | server{ .... listen[::]:80; ... } |
只監聽IPV6
12345 | server{....listen[::]:80defaultipv6only=on;...} |
監聽指定IPV6地址
1 2 3 4 5 | server{ .... listen[3608:f0f0:3002:31::1]:80; ... } |
重啟nginx
1 | /usr/local/nginx-1.7.0/sbin/nginx-sreload |