2

I have a server with 3 IPs and what to choose which IP apache2 uses, so it completely doesn't use the other 2 IPs anymore and Port 80 on those IPs is free for other applications. I searched, but I didn't get any result that answers my question...

OfficialCRUGG
  • 55
  • 1
  • 4

2 Answers2

2

You can specify the ip and the port where apache is listening using the directive "Listen" https://httpd.apache.org/docs/2.4/bind.html

NoNoNo
  • 1,963
  • 14
  • 20
  • 1
    But where do I have to do this? – OfficialCRUGG Jun 01 '19 at 17:19
  • In Apache's configuration. – Esa Jokinen Jun 01 '19 at 17:25
  • 1
    But where exactly? There is no "Listen" or something in the file – OfficialCRUGG Jun 01 '19 at 17:26
  • 2
    The [`Listen` directive](https://httpd.apache.org/docs/2.4/en/mod/mpm_common.html#listen) belongs to the server configuration context. This means it could be anywhere in the `httpd.conf`, but not inside `VirtualHost`, `Location` or `Directory`, as it's a global setting. You don't see it because it has a default value to listen on every interface. – Esa Jokinen Jun 01 '19 at 17:42
  • I did so now, but now the Website itself is not reachable anymore as well. I added `Listen iphere:80` & `Listen iphere:443` to the top of my `apache2.conf`. iphere is just a placeholder. But I can now use other apps on the other ips – OfficialCRUGG Jun 01 '19 at 17:57
  • @officialcrugg pls run apache2ctl -S and show us, however it could required to Set the servername – djdomi Jul 14 '19 at 17:22
0

Since I don't know which distro you use, on Debian and Ubuntu the default host is Set to Listen on All.

First, under /etc/apache2/ports.conf there is the list, which can be Set to Listen only on specific ip

Moreover I would suggest to Set the default host under

/etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>

Instead using *, Set this to the ip it should Listen on

I hope I could help you

Pete
  • 271
  • 1
  • 4
  • 19
djdomi
  • 1,599
  • 3
  • 12
  • 19
  • Wow! I already changed everything in my VHost, but the thing in the ports.conf made it work! Thank you so much! Only answer that helped. – OfficialCRUGG Jun 02 '19 at 15:12