6

How can I make it that my local Apache installation works only as http://localhost/ and never from outside like using the IP of my machine when connected to a network please?

Francisc
  • 153
  • 1
  • 3
  • 11

4 Answers4

7

Could try:
order deny,allow
allow from 127.0.0.1
deny from all

in a .htaccess file. - I use a similar setup to allow an external website to allow all access from our office IP, but ask for a password from any other.

4

Change your current "Listen" line to "Listen 127.0.0.1:80"

http://httpd.apache.org/docs/current/mod/mpm_common.html#listen

cagenut
  • 4,868
2

The easiest way would be to block ports 80 and 443 in the firewall for the machine that is hosting Apache. This would make external requests get blocked at the firewall.

Jay
  • 86
2

Some of this is borrowed from httpd.apache.org/docs/2.2/misc/security_tips.htm.

Add the following to httpd.conf :

  1. Restrict access to everything by default. This is from "Protect Server Files by Default":

    <Directory /> 
    Order Deny,Allow 
    Deny from all 
    </Directory>
    
  2. Then, allow access only in those areas you wish. In this example, /var/www/html is my DocumentRoot:

    DocumentRoot "/var/www/html"
    <Directory /var/www/html/> 
    Order Deny,Allow 
    Allow from 127.0.0.1 
    </Directory>
    
Stefan Lasiewski
  • 24,361
  • 42
  • 136
  • 188