Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu 12.04 server with a number of IPv4 addresses and a /64 of IPv6 addresses. I have it responding to its IPv6 addresses with ping6. I'd like the domains hosted on the server to go dual-stack, so IPv6-enabled visitors will be able to access its sites over IPv6, and everyone else will use IPv4.

Here's the relevant parts of my Apache config as it stands now:

ports.conf:

NameVirtualHost 199.192.201.82:80
Listen 199.192.201.82:80
Listen [2607:ff50:0:21::2]:80

httpd.conf:

<VirtualHost 199.192.201.82:80>
    ServerName  cdc.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>

<VirtualHost 199.192.201.82:80>
    ServerName  ipv6.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>

<VirtualHost 199.192.201.82:80>
    ServerName  dual.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>

cdc.nexussl.net has an A record pointing to 199.192.201.82, ipv6.nexussl.net has a AAAA record pointing to 2607:ff50:0:21::2, and dual.nexussl.net has both an A and a AAAA record.

With that setup, IPv4 works fine (They should all display a "You look lost" page), but visiting ipv6.nexussl.net or dual.nexussl.net from an IPv6-capable machine returns

Not Found
The requested URL / was not found on this server.
Apache/2.2.22 (Ubuntu) Server at ipv6.nexussl.net Port 80

dual.nexussl.net works correctly on an IPv4-only connection. Ultimately, I'd like all sites to be set up in DNS like dual.nexussl.net, with both A and AAAA records.

In Apache's config, I can't just use Listen 80, because other applications on that server use port 80 on other IPs. Apache should only use 199.192.201.82 as far as IPv4 goes.

As far as IPv6, should I give each site its own IPv6 address, and they'll just share one IPv4? I feel like that could get messy listing an IPv6 address in ports.conf for every site. Even if I'm having them all share an IPv6 address, how do I get Apache to serve sites correctly over IPv6?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

First, your AAAA records have to point to your IPv6 address, not to 199.192.201.82 (which is technically impossible, so I wouldn't be surprised that that's a typo).

Here is a correct config:

ports.conf:

Listen 199.192.201.82:80
NameVirtualHost 199.192.201.82:80

Listen [2607:ff50:0:21::2]:80
NameVirtualHost [2607:ff50:0:21::2]:80

httpd.conf:

<VirtualHost 199.192.201.82:80>
    ServerName  cdc.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>

<VirtualHost [2607:ff50:0:21::2]:80>
    ServerName  ipv6.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>

<VirtualHost 199.192.201.82:80 [2607:ff50:0:21::2]:80>
    ServerName  dual.nexussl.net

    DirectoryIndex index.php
    DocumentRoot /var/www

    LogLevel warn
    ErrorLog  /var/www/error.log
    CustomLog /var/www/access.log combined
</VirtualHost>
share|improve this answer
    
You're right, that was a typo. Your solution works perfectly! Thanks! –  Dan Nov 27 '12 at 2:21
    
was having a major headache with TLS on our server not being served for ipv6 which was recently rolled out in my area. this really helped me out. –  billynoah Jul 17 at 20:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.