2

Using Apache 2.4 on Ubuntu, I have the following in ports.conf:

Listen XX.73.44.57:80
Listen [2001:XX:0:2c38::39]:80

<IfModule ssl_module>
         Listen XX.73.44.57:443
         Listen [2001:XX:0:2c38::39]:443
</IfModule>

<IfModule mod_gnutls.c>
         Listen XX.73.44.57:443
         Listen [2001:XX:0:2c38::39]:443
</IfModule>

I'd like to have the following in my server configs:

 <VirtualHost *:80>

but that doesn't seem to work properly as the hosts don't respond. I've also tried:

 <VirtualHost *:80 [::]:80>

The following works:

<VirtualHost [2001:XX:0:2c38::39]:80 XX.73.44.57:80>

but I'd prefer a wildcard. Do I have to give the IP addresses explicitly?

2
  • Do the logs provide any hints as to why <VirtualHost *:80> doesn't work? It works for me along with Listen [::]:80.
    – kasperd
    Commented Jul 5, 2015 at 12:47
  • 1
    From what I can tell, it's because I have some hosts with IP addresses specified and other with wildcards. Apache only looks at * if there are no matches for the exact IP address. So for * to work I need to change all the <VirtualHost> lines to use * and listen on all IP addresses. Commented Jul 6, 2015 at 7:53

2 Answers 2

1

If you want to use a wildcard address (listen on all IP addresses) in a VirtualHost, you need your Listen directive to be listening on all IP addresses.

Listen 80
Listen 443
3
  • I have several IP addresses configured on the host, and only want Apache to listen on some of them. So I take it this means I have to give the IP addresses explicitly in both the Listen and VirtualHost directives? That's annoying as I was hoping to make my virtual hosts configs portable across machines. Commented Jul 5, 2015 at 9:14
  • Different machines are going to have the same IP address? Commented Jul 6, 2015 at 14:50
  • I have three IP addresses on the physical machine that Apache is running on. I want Apache to bind to one of those addresses on ports 80 and 443. I want another app (not Apache) to bind to port 80 on another one of those addresses, and yet another on port 443 on the third address. Commented Jul 7, 2015 at 14:46
0

Try putting Listen 0.0.0.0:80 in ports.conf instead of Listen 80. This helped me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .