Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,030
3,011
St. Louis, MO
Hello,

I have a Powermac G5 with Panther, Apache, PHP and MySQL. I write and test PHP scripts on it. But, how can I setup Apache so it can only be accessed through localhost? I'm on a college campus network and IT is strict about running servers, so is it possible to make the server appear to be nonexistant to the rest of the network without me actually having to unplug the network cable? thanks
 
I can think of 2 ways:

1. Change the port in httpd.conf (located at /etc/httpd/httpd.conf - root password required) --> http request usually use port 80;

2. Add the following at the end of httpd.conf and restart webserver :

Code:
<Directory /Users/*/Sites>
deny from all
allow from localhost
</Directory>

This will bloc access to your websharing directories from machines that arn't your local one.

You may want to do the same for the '/Library/WebServer/Documents' folder, which is the document root and contains Apache documentation.

-------

To edit the httpd.conf file (following are terminal commands),

1. Back it up:
Code:
sudo cp /etc/httpd/httpd.conf /etc/httpd/httpd.conf.old

2. To edit it:
Code:
sudo pico /etc/httpd/httpd.conf

Each time you change it, you need to restart the webserver: System Prefs->Sharing->WebSharing Off & On again.
 
Editing the httpd.conf will prevent people from accessing files on the server, but the server will still respond to requests on the http port (IE: it will say "Go away") However, most network scanning software will still flag it as an active server.

Better option is to use the OS X firewall to prevent access to the server. Thay way when something trys to connect, it wont even respond.
 
sgarringer said:
Better option is to use the OS X firewall to prevent access to the server. Thay way when something trys to connect, it wont even respond.

Yeah, that was my first thaught, but you can't block the port 80 if your websharing is running. At least not easily through System Prefs...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.