After discovering that my work PC has a fully working IPv6 internet connection (and therefore giving me the ability to test it), I decided to get my personal web server to work over IPv6 as well as IPv4.
The first challenge was to create a AAAA record for the domain, as well as the A record. Since I operate my own DNS servers running
bind, this was fairly straightforward – simply add AAAA records to the zone file for the web server(s). In my case that meant going from:
www IN A 22.214.171.124
www IN A 126.96.36.199 IN AAAA 2001:41d0:801:2000::a65
And then obviously restart/reload bind.
Then to get the webserver working was also pretty simple. I use the current default package version of
nginx on a recent version of Ubuntu (18.04) so I mainly had to ensure that in my nginx config files I was always listening on both IPv6 ports as well as IPv4 ports.
It turns out that a
listen 443 ssl;
both only listen on IPv4, but if you add a
listen [::]:<port> like so:
listen [::]:80; listen 80;
listen [::]:443; listen 443 ssl;
that will listen on both IPv4 and IPv6.
(Some documentation says that only the IPv6 line is required to have it listen on both v4 and v6, although that didn’t seem to work for me).
After making the change, restart nginx.
So far I’ve only changed this for one particular domain and it’s associated nginx configuration, but a quick
wget on my work PC shows things are working (in this case including the HTTP -> HTTPS redirect first – both requests were over IPv6):
$ wget www.tx9.co.uk --2018-09-14 13:04:42-- http://www.tx9.co.uk/ Resolving www.tx9.co.uk (www.tx9.co.uk)... 2001:41d0:801:2000::a65, 188.8.131.52 Connecting to www.tx9.co.uk (www.tx9.co.uk)|2001:41d0:801:2000::a65|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://www.tx9.co.uk/ [following] --2018-09-14 13:04:42-- https://www.tx9.co.uk/ Connecting to www.tx9.co.uk (www.tx9.co.uk)|2001:41d0:801:2000::a65|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 729 [text/html] Saving to: ‘index.html’ index.html 100%[===================>] 729 --.-KB/s in 0s 2018-09-14 13:04:42 (47.1 MB/s) - ‘index.html’ saved [729/729]