Created
June 17, 2011 18:58
-
-
Save benders/1032050 to your computer and use it in GitHub Desktop.
F5 BigIP iRules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when LB_FAILED { | |
HTTP::respond 503 content "System down for maintenance" noserver "Connection" "close" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when HTTP_REQUEST { | |
set request_uri [HTTP::uri] | |
set request_host [HTTP::header Host] | |
set request_user_agent [HTTP::header User-Agent] | |
set request_referer [HTTP::header Referer] | |
set request_size [HTTP::header Content-Length] | |
set virtual_addr [IP::local_addr] | |
set virtual_port [TCP::local_port] | |
} | |
when HTTP_RESPONSE { | |
set response_status [HTTP::status] | |
set response_size [HTTP::header Content-Length] | |
set priority [class lookup $virtual_addr vs-to-priority] | |
if { $priority eq "" } { | |
set priority "<191>" | |
} | |
HSL::send [HSL::open -proto TCP -pool chi-boss-syslog] "$priority |[IP::client_addr]|$virtual_addr:$virtual_port|[IP::server_addr]:[TCP::server_port]|$response_status|$request_size|$response_size|$request_uri|$request_referer|$request_user_agent|$request_host\n" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when HTTP_REQUEST { | |
# Only check POST requests | |
if {[HTTP::method] equals "POST"} { | |
if {[HTTP::header Content-Length] > 3000000} { | |
# Use default collect length | |
HTTP::respond 413 content "POST exceeded max size" | |
TCP::close | |
return | |
} | |
HTTP::header remove Expect | |
HTTP::header insert Connection close | |
if {[HTTP::header exists Expect]} { | |
log local0. "Expect header should be removed [HTTP::header value Expect]" | |
} | |
# Trigger collection of the request payload | |
HTTP::collect [HTTP::header Content-Length] | |
} | |
} | |
when HTTP_RESPONSE { | |
if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] > 0} { | |
HTTP::collect [HTTP::header "Content-Length"] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when HTTP_REQUEST { | |
switch [TCP::local_port] { | |
80 { | |
set proto http | |
} | |
443 { | |
set proto https | |
} | |
default { | |
drop | |
} | |
} | |
HTTP::header replace X-Forwarded-Proto $proto | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment