Question

I am adding ip like this :

Listen 127.0.0.1:80
Listen xxx.xxx.xxx.xxx:80

when restarting apache it giving me error.

XAMPP: Error 1! Couldn't start Apache!
XAMPP: Starting diagnose...
XAMPP: Sorry, I've no idea what's going wrong.
XAMPP: Please contact our forum http://www.apachefriends.org/f/

How to make localhost available to only 2 computers in lan.

Was it helpful?

Solution

Specifying Listen actually tells Apache on which ports and ip-addresses it should be hosting the server and not which ip-addresses can access the server. What you are looking for is an Apache Access Control and here you will see that you need to enable the mod_authz_host and then you can Allow or Deny hosts and ip-addresses.

In your httpd.conf look for the following line:

LoadModule authz_host_module modules/mod_authz_host.so

Make sure there is no '#' in front of the LoadModule

Now go down to your configured VirtualHost and add the following lines:

<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    #below add your acceptable IPs
    Allow from 127.0.0.0/12.12.12.12 
</Directory>

Note that using a hostname will incur a reverse DNS lookup so can be slow.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top