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 22.214.171.124 and 126.96.36.199, and blocks access from any other IP address:
Require ip 188.8.131.52 Require ip 184.108.40.206 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 220.127.116.11 and 18.104.22.168:
<RequireAll> Require all granted Require not ip 22.214.171.124 Require not ip 126.96.36.199 </RequireAll>
This would allow access to the site for all trafic except IP address 188.8.131.52 and 184.108.40.206.
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