挖井

类库大魔王的挖井日记

挖一口属于自己的井


Linode上nginx开启IPv6支持

之前就发现了,Linode是默认带一个IPv6地址的,最近公司里的项目要做一点跟IPv6相关的工作,我就想多了解点IPv6相关的东西,于是想到把我的web站点支持IPv6。

其实过程很简单,首先加一条DNS记录,AAAA指向IPv6地址。这时可以用命令dig yii.li AAAA查看是否生效:

$ dig yii.li AAAA

; <<>> DiG 9.8.3-P1 <<>> yii.li AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3703
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4

;; QUESTION SECTION:
;yii.li.				IN	AAAA

;; ANSWER SECTION:
yii.li.			300	IN	AAAA	2400:8900::f03c:91ff:fe73:f280

;; AUTHORITY SECTION:
yii.li.			3600	IN	NS	kurt.ns.cloudflare.com.
yii.li.			3600	IN	NS	olga.ns.cloudflare.com.

;; ADDITIONAL SECTION:
kurt.ns.cloudflare.com.	2548	IN	A	173.245.59.193
kurt.ns.cloudflare.com.	2548	IN	AAAA	2400:cb00:2049:1::adf5:3bc1
olga.ns.cloudflare.com.	30057	IN	A	173.245.58.137
olga.ns.cloudflare.com.	30057	IN	AAAA	2400:cb00:2049:1::adf5:3a89

;; Query time: 356 msec
;; SERVER: 64.104.123.245#53(64.104.123.245)
;; WHEN: Wed Jul 22 09:44:01 2015
;; MSG SIZE  rcvd: 195

然后修改nginx配置:

listen      [::]:80 ipv6only=on;
listen      80;
listen      [::]:443 ssl spdy ipv6only=on;
listen      443;

后面的ipv6only=on这种选项在整个配置中只要加一次就行了。重启nginx,看一下监听端口:

$ netstat -anltp | grep "\(443\|80\)"
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      -                 
tcp        0      0 :::80                       :::*                        LISTEN      -                   
tcp        0      0 :::443                      :::*                        LISTEN      -

最后,如果自己有IPv6环境,就访问一下,没有的话可以在http://ipv6-test.com/validate.php测一下看看是否生效。

BTW,我这blog也是支持IPv6的。

$ dig blog.minidump.info ANY 

; <<>> DiG 9.8.3-P1 <<>> blog.minidump.info ANY
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59877
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 2, ADDITIONAL: 4

;; QUESTION SECTION:
;blog.minidump.info.		IN	ANY

;; ANSWER SECTION:
blog.minidump.info.	5	IN	A	104.28.31.28
blog.minidump.info.	5	IN	A	104.28.30.28
blog.minidump.info.	5	IN	AAAA	2400:cb00:2048:1::681c:1f1c
blog.minidump.info.	5	IN	AAAA	2400:cb00:2048:1::681c:1e1c

;; AUTHORITY SECTION:
minidump.info.		4211	IN	NS	anna.ns.cloudflare.com.
minidump.info.		4211	IN	NS	ed.ns.cloudflare.com.

;; ADDITIONAL SECTION:
ed.ns.cloudflare.com.	84448	IN	A	173.245.59.111
ed.ns.cloudflare.com.	84448	IN	AAAA	2400:cb00:2049:1::adf5:3b6f
anna.ns.cloudflare.com.	63572	IN	A	173.245.58.102
anna.ns.cloudflare.com.	63572	IN	AAAA	2400:cb00:2049:1::adf5:3a66

;; Query time: 165 msec
;; SERVER: 64.104.123.245#53(64.104.123.245)
;; WHEN: Wed Jul 22 09:58:33 2015
;; MSG SIZE  rcvd: 265

本文地址:

https://minidump.info/blog/2015/07/enable-ipv6-with-nginx-on-linode/

上一篇

开始卖咖啡

本来只是妹子的同学老家产茶,要帮那同学卖茶,但是还没好的包装,所以想着先把店开起来,可以先卖点咖啡,咖啡来源就是喵咖啡了。店在微店和淘宝都有,分别适用手机和电脑两种环境,店铺地址仍然是https://shop.yii.li。喵咖啡是自己从国外进的咖啡豆(意大利产),在国内找加工厂烘焙磨粉,由专...…

Life 全文阅读
下一篇

T43终于彻底挂了

今天无聊地把老本子拿出来,因为之前发现它的显卡似乎已经有问题了,开机几分钟GUI就会卡死没有反应,所以只装了Archlinux,还没装X。顺手就敲了个sudo pacman -Syu让它跑着,跑着跑着,然后发现它不知道什么时候已经不亮了,屏幕黑了,插着电源线的指示灯也不亮了,按开关按钮也没反应...…

device 全文阅读