Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Restrict access to directories through ip address on Apache

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 245
    Comment on it

    Apache web server allows access based upon different conditions. For example we can restrict access to url http://firstexample.com/ (mapped to /var/www/public/images directory) from 192.165.1.0/24 network.

    Apache provides access based on different conditions such as domainname, IP address. Making a restriction on the basis of IP address we make changes in the apache configuration file as below:


    Configuration for Centos/Fedora

    Open httpd.conf file:-

    nano /etc/httpd/conf/httpd.conf

    Configuration for Debian/Ubuntu

    Open apache2.conf file:-

    nano /etc/apache2/apache2.conf


    Now for rectricting by IP we add following code in the above file:

    <Directory /path/of/folder>
                Order deny,allow
                Deny from all
                Allow from 192.165.2.1
    </Directory>
    

    If we want to allow access to IP begining with 192 with IP address with a specific pattern than we will write

    Allow from 192


    Now save file and restart apache web server:

    apache2 services restart (ubuntu)
    /etc/init.d/httpd restart (centos)
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: