Can't make a VirtualHost working with ipv6
I have a website served by apache. It works with IPv4 but not with IPv6. I have a 500 error.
Here is my ports.conf file :
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
NameVirtualHost *:80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
And my VHost :
<VirtualHost *:80 [::]:80>
DocumentRoot "/var/www/html/mysite.ca/www.mysite.ca"
ServerName mysite.ca
<Directory "/var/www/html/mysite.ca/www.mysite.ca">
allow from all
Options +Indexes
</Directory>
ServerAlias www.mysite.ca
</VirtualHost>
When I do netstat-tlnpt
, I have this :
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3577/master
tcp 0 0 0.0.0.0:453 0.0.0.0:* LISTEN 4484/perl
tcp 0 0 0.0.0.0:360 0.0.0.0:* LISTEN 3254/sshd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 3307/mysqld
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2923/vsftpd
tcp6 0 0 ::1:25 :::* LISTEN 3577/master
tcp6 0 0 :::443 :::* LISTEN 7240/apache2
tcp6 0 0 :::360 :::* LISTEN 3254/sshd
tcp6 0 0 :::80 :::* LISTEN 7240/apache2
It seems apache is already listening for IPv6 address.
I tried to add :
Listen [::]:80
Listen [::]:443
To my port file but I have this result when I restart apache :
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
I tried to change wildcars by static address and I have the same issue.
I have other websites that works with IPv6 on the same server. This is the only that doesn't work.
What can I do ?
Make sure apache2 is fully being shutdown. Possibly whatever is managing services doesn't know about a copy manually launched in the background. (run netstat when it should be stopped and make sure nothing's still listening)
Depending on your apache version, you may not need NameVirtualHost either. See https://httpd.apache.org/docs/current/upgrading.html
If you're getting a 500 error, then something is definitely listening on the port and responding. This should be logged in your error.log. If not, you may need to adjust logging options to include it. I don't see anything indicating whether you're running apache2.2 or 2.4 and the logging configuration is different between the two.
EDIT: See this page about LogLevel https://httpd.apache.org/docs/2.4/mod/core.html#loglevel
Make sure you have Listen
once per port per IP per complete config per server, maybe comment out the ones you're aware of until it starts without complaining and see if it's still starting on port 80/443
for ipv6 and ipv4, you only need
listen 80
listen 443 https
find /etc/httpd/ | xargs grep -sniH "listen"