skip to Main Content

I am trying to place apache restrict by ip.

I tested on my IP if by blocking myself or accept only the other IP.

Apache was restarted, i really don’t know which could be the problem

I could accessed on the page despite of the restriction

All examples which i found on web as below :

<Location /home>
        SetEnvIf X-Forwarded-For ^xxx.xxx.xxx.xxx access
        Order allow,deny
        Satisfy Any
        Allow from env=access
</Location>


<Location /home>        
        Order Deny,Allow
        Deny from All
        Allow from xxx.xxx.xxx.xxx
        Deny from All
        Satisfy Any
</Location>

<ProxyMatch "/home/*" >
    Order Deny,Allow
    Deny from all
    Allow from xxx.xxx.xxx.xxx
</ProxyMatch>


<LocationMatch "/home">
       Order Allow,Deny
       Allow from all
       SetEnvif X-Forwarded-For "xxx.xxx." DenyAccess
       Deny from env=DenyAccess
</LocationMatch>


<Location "/home">
       Order Allow,Deny
       Allow from all
       SetEnvIf X-Forwarded-For ^xxx.xxx. denyAccess
       Deny from env=denyAccess
</Location>


<Location "/home">
        SetEnvIf X-Forwarded-For ^xxx.xxx. access
        Order allow,deny
        Satisfy Any
        Allow from env=access
</Location>

Thanks

2

Answers


  1. You can do it via Require not ip xxx.xxx.xxx.xxx directive
    Documentation here: https://httpd.apache.org/docs/2.4/howto/access.html

    Login or Signup to reply.
  2. Apache 2.4 has a differing structure using Require

    <Files /home>
        Require all granted
        Require not ip xx.xx.xx.xx
    </Files>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search