Much to my consternation I noticed that my last post appeared almost six months ago. I hope I can increase again my posting frequency this year.
The last topic has been DNS resolving and this article shall be about IPv6 configuration in apache.
First we need to check whether our apache already listens to requests comming from IPv6. The default configuration on Debian in /etc/apache2/ports.conf says something like
NameVirtualHost *:80
Listen 80
This means: listen on port 80 of all addresses on this machine, including IPv6 ones. So in principle we are already done.
In case we want to restrict some interfaces to IPv4 or IPv6 access, we need to replace the general listen-directive with more restrictive ones, so for example:
listen 1.2.3.4:80
listen [1:2::4:5:6:7]:80
In the whole apache configuration IPv6 addresses need to be put in square brackets.
The same is also valid for virtual host configuration:
In this case any request, either via IPv4 or IPv6, will be handled by our apache:
<virtualhost *:80>
ServerName example.com
ServerAlias all.example.com
DocumentRoot /www/example.com/public_html
ErrorLog /www/example.com/logs/error_log
Customlog /www/example.com/logs/combined_log combined
</virtualhost>
In this case, the vhost is available only on a specific IPv6 address:
<virtualhost [1:2::4:5:6:7]:80>
ServerName example.com
ServerAlias ipv6.example.com
DocumentRoot /www/example.com/public_html
ErrorLog /www/example.com/logs/error_log
Customlog /www/example.com/logs/combined_log combined
</virtualhost>
In this case, the vhost is available only on a specific IPv4 address:
<virtualhost 1.2.3.4:80>
ServerName example.com
ServerAlias ipv4.example.com
DocumentRoot /www/example.com/public_html
ErrorLog /www/example.com/logs/error_log
Customlog /www/example.com/logs/combined_log combined
</virtualhost>
In this case, the vhost is available on specific IPv4 and IPv6 adresses:
<virtualhost 1.2.3.4:80, [1:2::4:5:6:7]:80>
ServerName example.com
ServerAlias special.example.com
DocumentRoot /www/example.com/public_html
ErrorLog /www/example.com/logs/error_log
Customlog /www/example.com/logs/combined_log combined
</virtualhost>
So there is really no magic in IPv6 and it is easy to use.