Jump to content
  • 0

Locking Down Admin Area By Ip


Question

Posted

I am attempting to lock down our admin area by IP via .htaccess with something like this:

order deny,allow
deny from all
allow from 123.456.78.9

<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>

I have also renamed (or re-routed) our admin directory to another name; in this example let's call it "abc".

 

So because there is no real "/abc/" directory I created one and placed this file inside it; however when I did that going to "/abc/" no longer redirected to "/abc/login/"; I had to manually go there.

 

Is there a way I can protect via IP without affecting anything else?

 

Thanks!

17 answers to this question

Recommended Posts

  • 0
Posted

 

Try something like the below in your main .htaccess file.

RewriteCond %{REQUEST_URI} ^/admin
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteRule .* - [F]

 

So I just add each IP I want to allow similar to have how you have added the one there?

  • 0
Posted

So I just add each IP I want to allow similar to have how you have added the one there?

 

Yes, by default Apache will add an AND between each condition. You can add [OR] at the end of the condition if you want OR instead.

 

This is regex so you could also add an IP range or whatever you want.

  • 0
Posted

Yes, by default Apache will add an AND between each condition. You can add [OR] at the end of the condition if you want OR instead.

 

This is regex so you could also add an IP range or whatever you want.

 

In this situation you would want AND though right!? It's basically saying if it's not that AND not that AND not that then send to forbidden?

 

As for ranges, would this be right?

RewriteCond %{REQUEST_URI} ^/admin
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REMOTE_ADDR} !^128\.0\.
RewriteRule .* - [F]
  • 0
Posted

 

In this situation you would want AND though right!? It's basically saying if it's not that AND not that AND not that then send to forbidden?

 

As for ranges, would this be right?

RewriteCond %{REQUEST_URI} ^/admin
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REMOTE_ADDR} !^128\.0\.
RewriteRule .* - [F]

 

AND is correct, I just mentioned that in case you wanted to use any other conditions. The IP range looks alright to me

  • 0
Posted

Hmmmmmmm....... couldn't get it to work. Oh well, will just wait for the update from Blesta I guess.

 

Is your url something like yourdomain.com/blesta/admin? If so you would need to change ^/admin to ^/blesta/admin

  • 0
Posted

Is your url something like yourdomain.com/blesta/admin? If so you would need to change ^/admin to ^/blesta/admin

 

Yeah, but I put it inside the blesta .htaccess file.

 

Side question: Noticed in your sig you nave a paypal express checkout on your "todo" list; is that the same as my feature request?

  • 0
Posted

Yeah, but I put it inside the blesta .htaccess file.

 

Even if you put it in the Blesta .htaccess it is still going to be running the regex on the full url so ^/admin won't work as ^ denotes the start of the string.

Side question: Noticed in your sig you nave a paypal express checkout on your "todo" list; is that the same as my feature request?

Yes it is, however my priorities have changed so you won't see it within the next few months. I also haven't had a good look at how Blesta handles merchant gateways that only store a token instead of the actual card details. It may not be possible yet without core changes.

  • 0
Posted

 

Even if you put it in the Blesta .htaccess it is still going to be running the regex on the full url so ^/admin won't work as ^ denotes the start of the string.

Yes it is, however my priorities have changed so you won't see it within the next few months. I also haven't had a good look at how Blesta handles merchant gateways that only store a token instead of the actual card details. It may not be possible yet without core changes.

 

No worries, thanks for the answer. :)

  • 0
Posted

This has been fully added to my next release of "Admin Tools" plugins , now you can set wich IP to access admin area , if not authorized redirect to 404 error page .

 

also i have implemented a new security way , to block access direct link of uninstalled plugins , now if the plugin is not installed no one can access it , i'm working now in modules too , to forbidden access if not installed .

 

need also block access to  client side by IP :)

 

i will finish the complete rewrite of this plugin and making some tests  and i will make it available next week .

  • 0
Posted

This has been fully added to my next release of "Admin Tools" plugins , now you can set wich IP to access admin area , if not authorized redirect to 404 error page .

 

also i have implemented a new security way , to block access direct link of uninstalled plugins , now if the plugin is not installed no one can access it , i'm working now in modules too , to forbidden access if not installed .

 

need also block access to  client side by IP :)

 

i will finish the complete rewrite of this plugin and making some tests  and i will make it available next week .

 

Most excellent! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...