htaccess ip restriction

Create .htaccess file inside your site folder and copy the below content to .htaccess file and replace "your_site_folder" to your's and also the IP

----------------------------------------------------------------------------------------------------------------------------------------
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/vhosts/your_site_folder/.htpasswd   
#path to htpasswd   
AuthGroupFile /dev/null


Satisfy Any
<Limit GET POST>
    Order Deny,Allow
    Deny from all
    Allow from 192.168.0.5              #(ip needed to be allowed)

    Allow from 192.168.0.6              #(ip needed to be allowed)
    Allow from 192.168.0.7              #(ip needed to be allowed)
    Require valid-user
</Limit>

----------------------------------------------------------------------------------------------------------------------------------------

OR                                                        


The htpassd file can also be added in /etc/apache2/site-available ceare a file in this folder and add the below line to that folder. And below is that if you are using proxy.

<VirtualHost *:80>
      ServerName kir.example.com

    ProxyRequests off

ProxyRequests off

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    <Location />
        AuthType Basic
        AuthName "Please Log in"
        AuthUserFile /var/www/myapp/.htpasswd            #path to htpasswd file
        Require valid-user
        Order allow,deny
        Allow from 000.00.00.00
        Allow from 000.00.00.00

        Allow from 000.00.00.00
        satisfy any
        ProxyPass http://localhost:3500/
        ProxyPassReverse http://kir.example.com:3500/
    </Location>

</VirtualHost>

 

No comments:

Post a Comment

Start and Stop ssh-agent

Below is the bash script used to start and stop ss-agent #!/bin/bash ## in .bash_profile SSHAGENT=`which ssh-agent` SSHAGENTARGS="...