1

I tried every combination but I keep getting error restarting Apache. Does anyone knows how to define a block inside apache virtualhost?

<VirtualHost "[2601:9ab4:48af:97::/64]:80" _default_:*>
<VirtualHost [2601:9ab4:48af:97::/64]:80 _default_:*>
<VirtualHost [::/64]:80 _default_:*>
<VirtualHost [::]/64:80 _default_:*>
<VirtualHost [*:/64]:80 _default_:*>
  • A bit more elaboration on why you are trying to do that would improve this question. – kasperd Feb 4 at 20:19
  • 2
    Do you really want your host to be listening on 2^64 = 18,446,744,073,709,551,616 IP addresses? A VirtualHost is defined in the apache documentation as listening on one address. – doneal24 Feb 4 at 20:22
  • To catch all the IPv6 address not defined in virtual host. – Saud Iqbal Feb 4 at 20:28
  • "To catch all the IPv6 address not defined in virtual host." Do you do that with IPv4? Host addressing really works the same way for IPv6 as it does for IPv4. – Ron Maupin Feb 4 at 20:31
  • 1
    @SaudIqbal Again, you want your host to listen on 18 quintillion addresses simultaneously? Is that what you mean by catching the addresses? – doneal24 Feb 4 at 20:37
2

First, I think you should listen to the commenters and limit your virtual host to one IP address. Even if you want to try to listen to more than one, maybe try getting one working first.

Second, I do not think you need the quotes around the IP address.

Third, have you tried any of those without the "/64" CIDR notation? Using the second line as an example:

<VirtualHost [2601:9ab4:48af:97::]:80>

I don't see anything about CIDR notation in the Apache docs here:

https://httpd.apache.org/docs/2.4/mod/core.html#virtualhost

  • 2
    I tried it but its not catching anything – Saud Iqbal Feb 4 at 20:50
  • 1
    What you would need to do here is have the line `<VirtualHost *:80> in your apache config file. Then in your network configuration, list each of the 18 quintillion IPv6 addresses as individual interfaces in your system. Note that you'll likely need a few petabytes to store the network configuration file. You'll also need a massive kernel rewrite to allow for this many interfaces. – doneal24 Feb 4 at 20:52
  • 1
    Also, make sure that nobody else is on the network with this address in use already or you'll get address conflicts. If you use ping6 -c1 on each address you might finish checking the network before the universe ends. – doneal24 Feb 4 at 20:54
2

TLDR; you can't use CIDR notation or IP-address ranges in VirtualHost directives.


Apache is configured to respond to requests on either :

  • a single specific IP-address and port number with the Listen directive
    Either an IPv6 addresss

    Listen [2601:9ab4:48af:97::1]:80
    

    or an IPv4 address

    Listen 127.0.0.1:80
    
  • multiple specific IP-addresses and port numbers by adding multiple Listen directives, one for each unique ip-address and port number

    Listen [2601:9ab4:48af:97::1]:80
    Listen [2601:9ab4:48af:97::2]:80
    Listen [2601:9ab4:48af:97::3]:80
    Listen 127.0.0.1:80
    Listen 127.0.0.2:81
    
  • every IP-address configured on the host by only setting the port number:

    Listen 80
    Listen 443
    

As far as I know you can't use a netmask or define a range of ip-addresses in the Listen directive.

After apache httpd is configured accept incoming connections by the above Listen directive(s) you can optionally create VirtualHost entries.

You can then create IP based virtual hosts (where you are again restricted to a specific IP-address), name based virtual hosts where the Host: header with a DNS domainname in http request headers will by handled by the VirtualHost with that hostname or hostname pattern in the ServerName or ServerAliasdirective and a default VirtualHost (typically the first VirtualHost entry) that handles all request that don't match a more specific IP based or Name Based VirtualHost. See: https://httpd.apache.org/docs/2.4/vhosts/details.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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