Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

httpd Deflector Maps

Discussion in 'Security' started by Frank Jance, Aug 11, 2018.

  1. Frank Jance

    Frank Jance Member

    Joined:
    Jan 13, 2018
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    I'm trying to set up deflector maps in httpd.conf to reroute bots based on agent and IP address. I entered the following code (Pre Main Include - all versions) in the Service Configuration » Apache Configuration » Include Editor:

    RewriteEngine on
    RewriteMap deflector txt:/home/user/maps/deflector_agent.map
    RewriteCond %{HTTP_REFERER} !=""
    RewriteCond ${deflector:%{HTTP_REFERER}} =-
    RewriteRule ^ %{HTTP_REFERER} [R,L]

    RewriteCond %{HTTP_REFERER} !=""
    RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
    RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]

    RewriteEngine on
    RewriteMap ip-deny txt:/home/user/maps/deflector_ip.map
    RewriteCond ${ip-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
    RewriteRule ^ - [F]

    However, this doesn't seem to be working. I entered my IP in the deflector_ip.map file but I'm not blocked from my site. What am I doing wrong?

    Thanks,
    Frank
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello Frank,

    You may want to add the entries as a virtual host include for all virtual hosts instead of a "Pre Main Include". Here's a thread where this is discussed (it's for different entries but the same principal applies):

    SOLVED - Auto Force TLS

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Frank Jance

    Frank Jance Member

    Joined:
    Jan 13, 2018
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Thanks, Michael. I tried both Pre VirtualHost Include and Post VirtualHost Include, but neither of those worked for me either. Is it because I'm using LiteSpeed instead of Apache? Or do I need more code to get what I've written to be recognized? The code I posted should work, as I copied it almost verbatim from the Apache website.

    I usually add these things to .htaccess, however this particular solution won't work there and is required to go in httpd.conf.
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice