Forum Discussion
hooleylist
Feb 16, 2009Cirrostratus
You're very close. To update the URI without a redirect you can use HTTP::uri. You'd use HTTP::header replace for the Host header because for whatever reason, you cannot rewrite the host using HTTP::host "newhost".
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"host.domain.com" {
HTTP::uri [string map {"/string" "/newstring" "page.jsp" "newpage.aspx"} [HTTP::uri]]
pool pool_name
}
default {
reject
}
}
}
The values for HTTP::uri and HTTP::host are cached within the same rule and event so logging the updated value won't show the change. But it is actually changed in the request sent to the server. If you'd like to verify this, you can add a second HTTP_REQUEST event which runs after the default priority HTTP_REQUEST event:
when HTTP_REQUEST {
log local0. "Priority 500: [IP::client_addr]:[TCP::client_port]: Original request to [HTTP::host][HTTP::uri]"
switch [string tolower [HTTP::host]] {
"host.domain.com" {
HTTP::uri [string map {"/string" "/newstring" "page.jsp" "newpage.aspx"} [HTTP::uri]]
pool pool_name
}
default {
reject
}
}
}
when HTTP_REQUEST priority 501 {
log local0. "Priority 501: [IP::client_addr]:[TCP::client_port]: Updated request to [HTTP::host][HTTP::uri]"
}
Aaron