I have around 10 different IPv4 addresses, and possibly another 10 IPv6 addresses with different suffixes.
The goal is to have Apache listen on ports 80 and 443 only on specific IP addresses, while reserving another dedicated IP address for a different (non-Apache) service that also needs to use port 443.
Does anyone know if Apache can work this way?
What are the potential risks or side effects?
Also, I’ve never tried modifying ports.conf before. Is this configuration actually supported and expected to work?
Sure, that’s how web servers used to work in the bad old days.
You need to be aware that Apache treats IP as the strongest matching characteristic, so if you switch to specifying IP addresses, you can no longer use *:80 for any VirtualHost on an IP that has an IP:80 VirtualHost, because in that case, the * host can never match.
I would generally recommend against wasting IPs like this, though.
I agree with Joe that it’s much easier to just use *:80 or *:443 to handle all requests.
That said, I think it will still work with *:80. It’s just that *:80 won’t match requests arriving on an IP that has a more specific IP:80 VirtualHost configured, which is actually the goal here.
And, I’m not sure why this approach is seen as old or bad practice. If the concern is that it may cause confusion or add complexity, then I agree that this is a good reason to avoid it. Otherwise, it’s just another type of server config—not good or bad.
Because it wastes IPv4 addresses for no useful purpose.
To be clear: There’s nothing wrong with making Apache listen on only one IP and using that specific IP for all your VirtualHosts, so you can use the other IP(s) for other services. That (other services needing port 443) is maybe a useful purpose (though Apache could also proxy to it, so no additional IPs are needed).
But, there’s no reason to use a bunch of IP addresses for different VirtualHosts.
What if one domain were involved in sending spam? With a private IP, the other domains on the system would not be affected. I remember that being the main reason each domain was justified in having its own IP.
Not for blocking, but policy routing. I used the wrong term as I call my pfsense a firewall, when in reality it is a router with firewall functionality.
What I’m trying to do is keep my IPv4/IPv6 addresses separate. I have 10 IP addresses in total, and I’d like to use 9 of them with Apache, while using the 10th IP address for another daemon that is not Apache.
I don’t want to use Apache as a reverse proxy for the other daemon. The other daemon needs to listen directly on port 443, just like Apache does.
So, in short, Apache would listen on ports 80 and 443 on 9 IP addresses, while the other daemon would listen directly on port 443 on the remaining IP address.