Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Block ip address
#1
Okay I'm a total noob when it comes to getsimple, so please bear that in mind. I was wondering if there was anyway in which I could block a certain ip address from accessing my website, or if I could block out all ip addresses except for my own. And if there is could you say how it is done (again I'm a total noob) Thanks
Reply
#2
You can put this in a .htaccess file in /admin
but with your ip

Code:
order deny,allow
deny from all
allow from 127.0.0.1
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
Thanks a lot, you really helped

(2014-03-10, 23:44:14)shawn_a Wrote: You can put this in a .htaccess file in /admin
but with your ip

Code:
order deny,allow
deny from all
allow from 127.0.0.1
Reply
#4
afaik there is not a plugin or anything specific to gs for this, but that is what I use, if you use something other than apache you will of course need some other way.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
I did it but now even I can't access the website (I did use my own ip) and when I delete the.htacces file I still can't access the website. HELP!
Reply
#6
What version of apache are you on ?

Also you sure it was successfully deleted ?
Where did you put it?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#7
Maybe it should be

Code:
order allow,deny
allow from all
deny from xxx.xxx.xxx.xxx

Where xxx.xxx.xxx.xxx the IP should be written that u wanna ban.
Reply
#8
Wrote up a little plugin to try automating what shawn said, except this is strictly for denying access to the given IPs; 1 per line. Does it in any way do the job for you? (if there are any problems, deactivate the plugin and delete the .htaccess file from /admin)


.php   blockip.php (Size: 1.37 KB / Downloads: 4)
Reply
#9
Denying? Is it at least a pattern of some sort? Why would you want to deny specific ips?
Also is this for back end only or frontend?

I imagine you would want deny specific on front and allow specific on back, they are kind of reversed roles
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
It can easily be modified to allow only those IPs instead.

To deny front-end scripts, would the IPs need to be appended to the .htaccess in the root?
Reply
#11
Well if you are making this a plugin then I would just use the first hook available and
$_SERVER["REMOTE_ADDR"] and match a pattern in php.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
Oh fair enough. So just store the list of IP addresses in either a text or xml file and compare it to that, then exit the PHP script immediately if it matches one of the IPs. I wondered if the htaccess method was in some way more elegant (since I've used the previous method on CUsers before), but that seems to work. I'll code it soon.

Also, when you say match a pattern, are you saying that the IP addresses stored by this plugin should allow for wildcards too?
Reply
#13
Of course htaccess is better, it stops at the request level, but a plugin would always work as opposed to sometimes.

Yeah wildcards are handy for subnets.

how were you doing it modifying the htaccess directly?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 2 Guest(s)