1. 程式人生 > >Nginx配置IPv6端口監聽及務器設置IPV6及Https支持並通過AppStore審核

Nginx配置IPv6端口監聽及務器設置IPV6及Https支持並通過AppStore審核

要求 虛擬網卡 只需要 inux vps ref 阿裏雲服務 www 技術

一、監聽端口

從Nginx 1.3的某個版本起,默認ipv6only是打開的,所以,我們只需要在監聽中加入ipv6監聽即可,不過推薦都手動加上比較好,代碼如下:

listen [::]:80 ipv6only=on;

server {
    listen 80;
    listen [::]:80 ipv6only=on;
    server_name
    index index.php index.html index.htm;
    root
}

編輯完畢後保存,然後使用命令檢測配置是否正確:

nginx -t

重啟nginx

systemctl restart nginx

檢測監聽是否已經成功,如果列表出現 :::80的監聽代表ipv6的監聽已經成功。

netstat -tuln

二、其他個性化操作

如果只想監聽ipv6,則去掉ipv4的配置,然後將ipv6設置為默認即可。

server {
    listen [::]:80 default ipv6only=on;

如果想監聽指定ipv6地址,則將中括號中的:: 換成 指定ipv6地址即可。

server {
    listen [2001:470:1f18:471::21]:80 default ipv6only=on;

三、阿裏雲服務器設置IPV6及Https支持並通過AppStore審核

蘋果上架要求:要求支持IPV6only(因為阿裏雲主機沒有IPV6only)

確認IPV6是否開啟:

方式1:使用ifconfig查看自己的IP地址是否含有IPv6地址。

技術分享圖片

技術分享圖片

方式2.查看服務監聽的IP中是否有IPv6格式的地址。(netstat -tuln)

技術分享圖片

開啟IPV6:

vim /etc/sysctl.conf

技術分享圖片

vim /etc/modprobe.d/disable_ipv6.conf

技術分享圖片

vim /etc/sysconfig/network

技術分享圖片

至此ipv6的服務器端支持已經完成,重啟服務器測試是否支持ipv6,重啟後, ifconfig查看ipv6的信息,有看到有關IPV6的輸出就可以

技術分享圖片

添加ipv6隧道:

1. 註冊Tunnel broker

https://www.tunnelbroker.net/
註冊很容易,就不講了,註冊需要郵箱驗證,,gmail、163能收得到認證郵件,qq還是一樣收不到

2.創建通道“Create Regular Tunnel”

填寫雲服務器ip以及選擇默認的隧道節點,點擊Create Tunnel創建。填寫ip都,如果出現“IP is a potential tunnel endpoint.”則證明可以添加ipv6隧道,一般隧道節點系統已經默認分配,可以手動選擇,大家可以在自己的雲服務器上分別ping一下這些ip,選時延低的。

技術分享圖片

3.創建ipv6隧道及路由

到下一頁面切換到Example configurations選項卡,如果你的VPS是centOS/Debian這些常見Linux的話,下拉菜單選擇Linux-route2,出現了設置的命令,復制到自己的雲服務器上運行。

技術分享圖片

4.測試ipv6

技術分享圖片

添加ipv6的dns服務器,在最後添加nameserver 2001:4860:4860::8888,nameserver 2001:4860:4860::8844谷歌的ipv6 dns服務器

# vim /etc/resolv.conf
options timeout:1 attempts:1 rotate
nameserver x.x.x.x
nameserver x.x.x.x
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
# ping6 -c 5 ipv6.google.com
PING ipv6.google.com(tsa03s01-in-x0e.1e100.net) 56 data bytes
64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=1 ttl=55 time=25.5 ms
64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=2 ttl=55 time=25.5 ms
64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=3 ttl=55 time=33.1 ms
64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=4 ttl=55 time=25.5 ms
64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=5 ttl=55 time=25.4 ms

--- ipv6.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4031ms
rtt min/avg/max/mdev = 25.473/27.040/33.180/3.073 ms

阿裏雲服務配置

代理配置好之後服務器中執行ifconfig命令,找到he-ipv6虛擬網卡,找到scope為Global 的ipv6地址,在阿裏雲後臺配置AAAA記錄為上面提到的ipv6地址

技術分享圖片

阿裏雲文檔:https://help.aliyun.com/knowledge_detail/39813.html
在線測試:http://ipv6-test.com/validate.php

Nginx配置IPv6端口監聽及務器設置IPV6及Https支持並通過AppStore審核