<![CDATA[ Restrict Manager by IP Addresses, without breaking CAPTCHA - My Forums]]> https://forums.modx.com/thread/?thread=45029 <![CDATA[Re: Restrict Manager by IP Addresses, without breaking CAPTCHA]]> https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-463882
Example:

# =====================================================
# Allow manager access to specific IPs only
Options +FollowSymlinks
RewriteEngine On
 
# Deny by IP
RewriteCond %{REMOTE_ADDR} !^(123\.123\.123\.123)$
RewriteCond %{REMOTE_ADDR} !^(124\.124\.124\.124)$
RewriteCond %{REMOTE_ADDR} !^(125\.125\.125\.125)$
RewriteCond %{REQUEST_FILENAME} !/includes/veriword\.php$
RewriteRule ^(.*)$ ../index.php?q=$1 [L,QSA]
# =====================================================


Got the info from http://www.netshinesoftware.com/blog/restricting-access-to-a-url-by-ip-address-using-mod-rewrite/]]>
orionweb Apr 22, 2013, 09:20 AM https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-463882
<![CDATA[Re: Restrict Manager by IP Addresses, without breaking CAPTCHA]]> https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-463880 orionweb Apr 22, 2013, 09:16 AM https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-463880 <![CDATA[Re: Restrict Manager by IP Addresses, without breaking CAPTCHA]]> https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259338 sottwell Jul 16, 2009, 08:42 PM https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259338 <![CDATA[Re: Restrict Manager by IP Addresses, without breaking CAPTCHA]]> https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259337 ]]> mrhaw Jul 16, 2009, 05:34 PM https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259337 <![CDATA[Restrict Manager by IP Addresses, without breaking CAPTCHA]]> https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259336 Figured this might be helpful to others. In attempting to lock down all our systems as much as possible, and in seeing many old exploits being attempted in our log files, I decided to only allow MODx /manager/ access to approved IPs. A simple "deny from all" worked, but it broke CAPTCHA on our eforms, since the veriword.php is in the /manager/includes/ path.

So... mod rewrite to the rescue. If anybody sees any issues with this code or the approach in general I’d love to know. We plan on extending/reworking this to tie into our system-wide port knocking, but that’ll be down the road.
# =====================================================
# Allow manager access to specific IPs only
Options +FollowSymlinks
RewriteEngine On

# Deny by IP
RewriteCond %{REMOTE_ADDR} !^(123\.123\.123\.123)$
RewriteCond %{REQUEST_FILENAME} !/includes/veriword\.php$
RewriteRule ^(.*)$ ../index.php?q=$1 [L,QSA]
# =====================================================


Just replace the RewriteEnging Off line with this bit. It seems to work well in my testing so far, but if I’ve missed anything please let me know.]]>
The Man Can! Jul 16, 2009, 05:24 PM https://forums.modx.com/thread/45029/restrict-manager-by-ip-addresses-without-breaking-captcha#dis-post-259336