I am trying to compose an irule which examines a ‘POST’ in http header, doesn’t care about case as it may be capitals or not, and processes as normal if that value is present. If that value is NOT present - reject the inbound connection.
Here is where I’m at:
when HTTP_REQEUST {
set keyvalue 0
if { [HTTP::method] equals “POST”} {
set http_headers [HTTP::header names]
foreach header $http_headers {
if {tolower $header equals “somevalue”} {
set keyvalue if we find the header
keyvalue == 1
}
}
if {$keyvalue ne 1} {
TCP::close
}
}
}
^^This is not taking into the LTM v9.4.5, so I assume I have some formatting error or other issue.^^
To make sure I understand what you’re trying to do:
1. Only examine POSTs.
2. Reject POST unless a certain header exists.
Are you looking for a certain header name, or any header that has a certain value? The rules above loop through every single header so will be inefficient if you’re just looking for a specific one.
The header name matching in [HTTP::header value NAME] isn’t case sensitive. So you could just look for the header name without a loop or setting the name to lower case.
This should work to check close TCP connections when a POST without a required header name is parsed:
when HTTP_REQUEST {
Check for POST requests
if {[HTTP::method] eq "POST"}{
if { not ([HTTP::header exists "my_required_header_name"])}{
TCP::close
}
}
}