Forum Discussion
TJ_Vreugdenhil
Aug 30, 2011Cirrus
Parse errors
I am trying to fight the parse errors using the GUI and the iRule editor line by line, however I am getting stuck at line 8 using the iRule below for 10.x
when HTTP_REQUEST {
log...
hooleylist
Aug 30, 2011Cirrostratus
There were quite a few mismatched curly and square braces. Also, you need to use the keyword "content" with HTTP::respond. Can you try this? I haven't checked it fully for logic, but it loads at least.
when HTTP_REQUEST {
logging for debug purposes. The following message in particular will place heavy load on the system. Remove for prod!
log local0.info "processing request for [HTTP::host][HTTP::uri]"
handle the */awdServer/* case.
if {[HTTP::uri] contains "/awdServer/"} {
if the Referer header does not exist this is a hard-bookmarked or malicious request and it will be logged and rejected.
if { [HTTP::header exists "Referer"] } {
if { [HTTP::header Referer] equals "" } {
log local0.warn "request for [HTTP::host][HTTP::uri] was dropped due to a null Referer header"
HTTP::respond 404 content "Object not found."
return
}
set ref_query [URI::query [HTTP::header "Referer"]]
set orig_query [HTTP::query]
set servlet [URI::query ${ref_query} servlet]
set awd_uri "${servlet}?${orig_query}&${ref_query}"
log local0.info "rewriting URI from [HTTP::uri] to ${awd_uri}"
HTTP::uri ${awd_uri}
} else {
log local0.warn "request for [HTTP::host][HTTP::uri] was dropped due to a missing Referer header"
HTTP::respond 404 "Object not found."
}
}
handle the /awd/ case
if { [HTTP::uri] starts_with "/awd/"} {
if the Referer header does not exist this is a hard-bookmarked or malicous request and it will be logged and rejected.
if { [HTTP::header exists "Referer"] } {
if { [HTTP::header "Referer"] equals "" } {
log local0.warn "request for [HTTP::host][HTTP::uri] was dropped due to a null Referer header"
HTTP::respond 404 content "Object not found."
return
}
grab the query string from the Referer header
set ref_uri [URI::query [HTTP::header Referer]]
grab the Platform from the Referer header query string, if present
if { [URI::query $ref_uri platform] ne "" } {
set ref_Platform "[URI::query $ref_uri platform]/"
}
collect the CLIENT value from the Referer header query string, if present.
if { [URI::query $ref_uri client] ne "" } {
set ref_Client [URI::query $ref_uri client]
}
if there was a host value in the Referer query string, rewrite the Host header
set orig_URI [HTTP::uri]
if { [URI::query $ref_uri host] ne "" } {
set ref_Host [URI::query $ref_uri host]
log local0.info "rewriting Host header [HTTP::host] to $ref_Host"
HTTP::header replace Host $ref_Host
}
rewrite the URI to /PLATFORM/CLIENT/OriginalURI
set awd_uri "/${ref_Platform}${ref_Client}${orig_URI}"
log local0.info "rewriting [HTTP::uri] to ${awd_uri}"
HTTP::uri $awd_uri
load-balance to the AWD Pool
pool http_test
} else {
log local0.warn "request for [HTTP::host][HTTP::uri] was dropped due to a missing Referer header"
HTTP::respond 404 content "Object not found."
}
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects