Forum Discussion
How do you block empty user-agents?
Hi,
I want to create an iRule to block empty user-agents from hitting our web site instead of letting IIS do it. I've read several posts and came up with this one. Is this ok?
Thanks
Eddie
- EddieJK_26590
Nimbostratus
This is the iRule:
if { [HTTP::header exists "User-Agent"]} { if { [HTTP::header "User-Agent"] equals "" } { reject } }
- Vijay_E
Cirrus
iRule looks to be good. Try it out. Make sure to add "when HTTP_REQUEST" as the event.
- EddieJK_26590
Nimbostratus
I am getting the following error:
The requested object name (user agents) is invalid
- Vijay_E
Cirrus
Remove the quotes around User-Agent
- EddieJK_26590
Nimbostratus
I changed it to the following below, but still have the same error.
when HTTP_RESPONSE { if { [HTTP::header exists User-Agent]} { if { [HTTP::header User-Agent] equals "" } { reject } }
- Vijay_E
Cirrus
If you need to block incoming request from client, you need to use HTTP_REQUEST
- David__Pasch
Altostratus
I was not able to test these, but either should get you the results you are looking for:
when HTTP_REQUEST { if {[class match [HTTP::header "User-Agent"] equals ""]} { reject }}
OR
when HTTP_REQUEST { if { [HTTP::header exists User-Agent]} { if { [HTTP::header User-Agent] equals "" } { reject }}}
Good Luck!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com