Control website access by IP address
Cloud Sites uses Apache 2.4 for its PHP environment. The use of Apache 2.4 simplifies how you block or allow access by IP address to your website compared to earlier releases of Cloud Sites.
Allow only specific IP addresses
To block all visitors except a specific IP address, with an optional message for blocked visitors, run the following code in the .htaccess file that contains your rules:
Require ip <ip address> ErrorDocument 403 "Some message you want to show blocked users"
The following example allows access to the site only for IP addresses 184.108.40.206 and 220.127.116.11, and blocks access from any other IP address:
Require ip 18.104.22.168 Require ip 22.214.171.124 ErrorDocument 403 "This site can only be accessed within the network"
Block only specific IP addresses
To block only specific IP addresses but allow other traffic through, run the following code in the .htaccess file that contains your rules:
<RequireAll> Require all granted Require not ip <ip address> </RequireAll>
The following example allows access to the site for all traffic except IP addresses 126.96.36.199 and 188.8.131.52:
<RequireAll> Require all granted Require not ip 184.108.40.206 Require not ip 220.127.116.11 </RequireAll>
This would allow access to the site for all trafic except IP address 18.104.22.168 and 22.214.171.124.
For more information, see the Apache documentation about access control.
Continue the conversation in the Rackspace Community.
©2016 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License