blocking all ips except localhost

Discussion in 'Apache' started by szms, Dec 25, 2010.

  1. #1
    Hi..

    I am using xammp in my local and trying plan to block a folder.

    Say my machines IP is 45.45.45.45 and I am accessing the folder names "bob" from another machine (LAN) via http.

    so http://45.45.45.45/bob works just fine.

    Now, if I want to block this folder from accessing another machine (LAN), but still need to access to that dir from my local via http (http://localhost/bob), what should my .htaccess file look like.

    I tried following, but it blocks me accessing this folder from my local machine as well.

    order deny,allow
    deny from all
    allow from localhost
     
    szms, Dec 25, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    Try:

    <Limit GET PUT POST>
    order deny,allow
    deny from all
    allow from 127.0.0.1
    </Limit>
    Code (markup):
    Or change 127.0.0.1 to your machines IP
     
    tolra, Dec 25, 2010 IP
  3. szms

    szms Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just put following on .htaccess file inside the folder that I wanted to restrict.

    <Limit GET PUT POST>
    order deny,allow
    deny from all
    allow from 127.0.0.1
    </Limit>
    Code (markup):
    After restarting Apache, I am getting following errors. I also get similar error if use the IP of my local.


    Server error!
    
    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
    
    If you think this is a server error, please contact the webmaster.
    Error 500
    127.0.0.1
    12/26/2010 11:53:29 AM
    Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 
    HTML:
     
    szms, Dec 26, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    Is there anything else in your .htaccess as it's defiantly right.
     
    tolra, Dec 26, 2010 IP
  5. szms

    szms Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No, that's all I have in my .htaccess file.

    Just wondering if you happened to test something similar.
     
    szms, Dec 26, 2010 IP
  6. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #6
    Yes, tried it just as I posted it on my xampp install and it worked just fine. The install I have is of 1.7.3 and not customised at all.
     
    tolra, Dec 26, 2010 IP
  7. jarrodw

    jarrodw Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Change the Listen directive in your apache config to only listen on 127.0.0.1

    There is no need for elaborate .htaccess rules.
     
    jarrodw, Dec 29, 2010 IP
  8. szms

    szms Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    jarrodw,

    If I change the Listen directive in my apache config to only listen on 127.0.0.1, then http://45.45.45.45/bob would not work. If you follow my initial issue.
     
    szms, Dec 31, 2010 IP