Results 1 to 9 of 9

Thread: Configuring Apache for local machine only, need to close port 80

  1. #1

    Configuring Apache for local machine only, need to close port 80

    This is kind of a follow up for my other post in this forum about my ISP.

    Someone over at SitePoint recommended that I configure apache to only use the localhost address (127.0.0.1) by changing the "Listen" parameter in httpd.conf.

    Can anyone explain how this is done or explain what I need to do to close the ports but still be able to use the apache server to test locally?

  2. #2
    Chronic Entrepreneur
    Join Date
    Nov 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    1,112
    When you say "test locally" do you mean that you'll be running your web browser on the same computer that's running apache, or do you mean that you'll be running your web browser on one machine on your local network and connecting to a second machine on your local network that's running apache?

  3. #3
    Quote Originally Posted by Westech
    When you say "test locally" do you mean that you'll be running your web browser on the same computer that's running apache, or do you mean that you'll be running your web browser on one machine on your local network and connecting to a second machine on your local network that's running apache?

    Well the only thing I need the apache webserver for is to test like small php scripts and such so I do not have to upload them to my webserver and waste time that way.

    So my web browser will be running the same machine as apache

  4. #4
    Chronic Entrepreneur
    Join Date
    Nov 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    1,112
    First, make a backup of your httpd.conf file in case you break something while editing it.

    Open httpd.conf and find the line that begins with ServerName. Edit it so that it looks like this:

    ServerName 127.0.0.1

    Then find the line that begins with Listen and then an IP address or hostname. Edit it to look like this:

    Listen 127.0.0.1

    If you find a second "Listen" line that designates port 80, leave it alone. It should already read:

    Listen 80

    As long as the only listen lines in httpd.conf that are not commented out with a # are:

    Listen 127.0.0.1
    and
    Listen 80

    Then Apache will only accept connections from your local machine on port 80. Restart apache to make your changes take effect. You can test to see if it worked by typing 127.0.0.1 into your web browser. If it worked you should see a default apache page.

    This is all off of the top of my head, but I think it should work. If it doesn't, just restore your original httpd.conf file from your backup and restart apache again and you'll be no worse off than you were before.

    If you want to be extra safe, you can also configure your firewall to block INBOUND connections on port 80. Make sure you don't block outbound port 80 or you won't be able to load any external webpages from that computer.

  5. #5
    Quote Originally Posted by Westech
    First, make a backup of your httpd.conf file in case you break something while editing it.

    Open httpd.conf and find the line that begins with ServerName. Edit it so that it looks like this:

    ServerName 127.0.0.1

    Then find the line that begins with Listen and then an IP address or hostname. Edit it to look like this:

    Listen 127.0.0.1

    If you find a second "Listen" line that designates port 80, leave it alone. It should already read:

    Listen 80

    As long as the only listen lines in httpd.conf that are not commented out with a # are:

    Listen 127.0.0.1
    and
    Listen 80

    Then Apache will only accept connections from your local machine on port 80. Restart apache to make your changes take effect. You can test to see if it worked by typing 127.0.0.1 into your web browser. If it worked you should see a default apache page.

    This is all off of the top of my head, but I think it should work. If it doesn't, just restore your original httpd.conf file from your backup and restart apache again and you'll be no worse off than you were before.

    If you want to be extra safe, you can also configure your firewall to block INBOUND connections on port 80. Make sure you don't block outbound port 80 or you won't be able to load any external webpages from that computer.

    Thanks I'll try it. I haven't actually used it for a while, as I've not needed to. So ever since I got that email from my ISP I've just turned apache off. I'll try this and see how it goes. I appreciate the help!

  6. #6
    Okay, sorry for the delay. But I did what you said and seems to have worked. When I type in 127.0.0.1 in my address bar I see the default apache page. So by seeing this, that should make it look like to my ISP that Port 80 is not open anymore correct?

  7. #7
    Senior Member AndyH's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    553
    Do you have a firewall?

    Block port 80 if you do.
    New website released. ya rly!

  8. #8
    Yes, I have Kerio Personal Firewall. I've got Apache incoming blocked or "deny" as it is in Kerio, but I don't see anything that actually allows me to block port 80. Are you familiar with that firewall? It's quite good, I just don't see that feature...?

  9. #9
    Registered
    Join Date
    Oct 2014
    Posts
    14
    I really liked this*information.

Similar Threads

  1. IIS and Apache open to the outside on one machine
    By bwall in forum Web Hosting & Servers
    Replies: 0
    Last Post: 11-19-2005, 02:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •