The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

htaccess blocking IP's

Discussion in 'General Discussion' started by keat63, May 5, 2016.

  1. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    765
    Likes Received:
    20
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    One of my sites is on a hosted cpanel, where I have no access to root, I don't have CSF etc etc.

    It has a CGI script that allows for a user to leave a comment, however, it seems that I'm under some sort of bot attack.

    I thought that I'd get clever by renaming the CGI file and updating any calls for this file.
    This worked in the respect that the bots are no longer making updates to the comments.
    However, they are still hitting the site.

    Rather than trying to add each and every subnet which comes, I'd like to try and block all IP's which call for the old CGI file.

    Is this possible with .HTACCESS ??
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Sure, find the icon in your cPanel called "IP Blocker".
     
  3. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    765
    Likes Received:
    20
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Doesn't IP blocker require me to insert these IP's manually, which is what I'm trying to avoid.
    Also, this affects every subdomain on the Cpanel, which appears to have a detrimental affect with some of the -Ecommerce sites.

    I did find this which I'm just toying with.

    <files myfile.txt>
    order allow,deny
    deny from all
    </files>
     
  4. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    765
    Likes Received:
    20
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    And that didn't work, I still see them in the visitors log.
     
  5. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    I'm a bit confused I guess. There is no automated way that I know of to block IP addresses you don't want visiting your site. When you add an IP there as mentioned, its added to the htaccess that you asked about.

    Yes, if you block an IP using the "IP Blocker" it should block all access to the account. Blocking an IP on one part of your site, but not another to avoid any detrimental affects makes no sense to me.
     
  6. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    765
    Likes Received:
    20
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    The cpanel account is split in to subdomains.
    A few of the sites on these subdomains have cubecart which uses some sort of htaccess rewrite rule for SEO purposes.

    The moment you start messing with IP Blocker, it does something to the htaccess file across all subdomains, which breaks the cubecart sites.

    I want to just modify the htaccess file on one particular subdomain, without affecting any of the others.
     
  7. deadlock

    deadlock Well-Known Member

    Joined:
    May 12, 2002
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    This does what you want it to do. The visits will still show in the access-logs (if that's what you mean) but if you take a closer look you will see they are "404" entries. The page will show as "Forbidden" (you can see that for yourself). The botter will eventually notice this and stop the requests.
     
  8. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    765
    Likes Received:
    20
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Its Apache 2.4 and seems needs a little different approach.

    I added:

    <RequireAll>
    Require all granted
    Require not ip xxx.xx.xx (a short list of class c's)
    </RequireAll>
    <files myfile.txt>
    order allow,deny
    deny from all
    </files>

    hopefully, they will go away.
     
Loading...

Share This Page