Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Very new to mod_sec

I want to block a UA string and I noticed there are a few types:

SecRule HTTP_User-Agent

What is the real difference between them?

My block:

SecRule REQUEST_HEADERS:User-Agent "perl" "phase:2,pass,msg:'Perl based user agent identified'"

Do I need to set a SecDefaultAction phase:2,deny,status:403,log,auditlog before that? Then any SecRule below that follows that action right?

share|improve this question
up vote 1 down vote accepted

I think you should rather use a SecDefaultAction to pass, and then to user the filter about perl user agent, to allow only this one. (If that's what you're really trying to do!)

SecDefaultAction phase:2,pass,status:403,log,auditlog

SecRule REQUEST_HEADERS:User-Agent "!perl" "phase:2,deny,msg:'Perl based user agent identified'"

I'm pretty sure this will work, but haven't tested it yet. And about your question concerning the differences between the two types, I think there isn't any.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.