iRule HTTP::Redirect not working on some URLs (aborting connection)
Hi all, I'm a bit stumped.... class SharePoint-Redirect_Urls_Old_Path_To_New_Path_DataGroup { { "/ALL_ENTRIES_MUST_BE" { "LOWER_CASE_TO_MATCH" } "/cop/da-apt" { "/co/da-apt" } "/cop/hrp-prh" { "/co/hrp-prh" } "/cop/knowledge" { "/co/knowledge" } "/cop/ypn-rjp" { "/co/ypn-rjp" } "/projects-projets" { "/pj" } "/governance-gouvernance" { "/gv" } "/communities-communautes" { "/co" } "/search/" { "/search-recherche/" } } } rule SharePoint-Redirect_Urls_Old_Path_To_New_Path { when RULE_INIT { Set this option to 1 to log messages (to /var/log/ltm by default) set static::log_old_to_new_path_redir 1 } when CLIENT_ACCEPTED { if {[TCP::local_port] eq 443} { set CLIENT_HTTP_TYPE "https" } else { set CLIENT_HTTP_TYPE "http" } } when HTTP_REQUEST { set MATCH_FOUND [class match [string tolower [HTTP::path]] starts_with SharePoint-Redirect_Urls_Old_Path_To_New_Path_DataGroup] if {($static::log_old_to_new_path_redir) && ($MATCH_FOUND)}{ set CLIENT_ADDR [IP::client_addr] set XFF [HTTP::header X-Forwarded-For] set ID "[TCP::local_port][expr { int(100000000 * rand()) }]" seconds from epoch + random number set ID "[TCP::local_port]-[clock seconds]-[expr { int(100000000 * rand()) }]" set REQUEST_RECEIVE [clock clicks -milliseconds] set HTTP_LPATH [string tolower [HTTP::path]] } if {$MATCH_FOUND} { set KEY [class match -name $HTTP_LPATH starts_with SharePoint-Redirect_Urls_Old_Path_To_New_Path_DataGroup] set VAL [class match -value $HTTP_LPATH starts_with SharePoint-Redirect_Urls_Old_Path_To_New_Path_DataGroup] set REPLACED_PATH [string map -nocase [list $KEY $VAL] [HTTP::uri]] set REDIRECT_URL "$CLIENT_HTTP_TYPE://[HTTP::host]$REPLACED_PATH" if {($static::log_old_to_new_path_redir) && ($MATCH_FOUND)}{ log local0.info "URI_PATH:[HTTP::path] || KEY:$KEY || VAL:$VAL || REPLACED_PATH:$REPLACED_PATH || REDIRECT_URL:$REDIRECT_URL - SRC:$CLIENT_ADDR ID:$ID" } HTTP::redirect $REDIRECT_URL } } when HTTP_REQUEST_SEND { if {($static::log_old_to_new_path_redir) && ($MATCH_FOUND)}{ set REQUEST_SEND [clock clicks -milliseconds] set REQUEST_WAIT [expr {$REQUEST_SEND - $REQUEST_RECEIVE}] log local0. "URI PATH: $HTTP_LPATH - SRC:$CLIENT_ADDR ID:$ID" } } when HTTP_RESPONSE { if {($static::log_old_to_new_path_redir) && ($MATCH_FOUND)}{ set RESPONSE_TIME [expr {[clock clicks -milliseconds] - $REQUEST_SEND}] log local0. "URI PATH: $HTTP_LPATH - HTTP[HTTP::status] $RESPONSE_TIME\ms/$REQUEST_WAIT\ms [LB::server addr] - SRC:$CLIENT_ADDR ID:$ID" } } } The lines entries for projects to search in the data group all fail to redirect... I get a browser aborted. However, the log entries show up as successful.... DOES actually redirect: Rule SharePoint-Redirect_Urls_Old_Path_To_New_Path : URI_PATH:/cop/ypn-rjp/ || KEY:/cop/ypn-rjp || VAL:/co/ypn-rjp || REPLACED_PATH:/co/ypn-rjp/ || REDIRECT_URL:https://collab.MY_DOMAIN_HERE/co/ypn-rjp/ - SRC:10.128.42.207 ID:1458297076443-20424180 DOES NOT actually redirect (aborted) Rule SharePoint-Redirect_Urls_Old_Path_To_New_Path : URI_PATH:/communities-communautes/cts-cst/ || KEY:/communities-communautes/cts-cst || VAL:/co/cts-cst || REPLACED_PATH:/co/cts-cst/ || REDIRECT_URL:https://collab.MY_DOMAIN_HERE/co/cts-cst/ - SRC:10.128.42.207 ID:1458297033443-17874026 The events HTTP_REQUEST_SEND and HTTP_RESPONSE never fire (no logging) which makes sense if the redirect is happening in the HTTP_REQUEST. I added them in to ensure that nothing was actually being sent to the back-end servers. Do any of you have any insight as to why this would happen? Cheers!230Views0likes1CommentHow to change Server header sent by HTTP::redirect ?
Hi, I'm using a very simple iRule to redirect http traffic to https URL. But the response contains a Server header with BigIP as value. How can I change this? Here is the iRule I'm using: when HTTP_REQUEST { HTTP::redirect "https://some.web.site?target=[URI::encode http://[HTTP::host][HTTP::uri]]" } Here is the response I get: HTTP/1.0 302 Found Location: https://some.web.site?target=http%3a%2f%2fblah%2f Server: BigIP Connection: close Content-Length: 0 I'd like to replace BigIP by some.web.site. I've tried the following but it is not working... when HTTP_RESPONSE { HTTP::header replace Server "some.web.site" } Is it possible? Any suggestion? Thanks, ChristopheSolved824Views0likes7CommentsBIG-IP : irule syntax to construct url
F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi Can anyone see a problem with syntax with this iRule : when HTTP_REQUEST { set host [HTTP::host] if { not ([string tolower [HTTP::host]] starts_with "www.") } { set host "www.[HTTP::host]" } HTTP::redirect "https://$host[HTTP::uri]" } This irule lives on an http vip. The intention is to prepend "www." to the host ( if not already present ).258Views0likes2Commentshttp redirect issue with $ character
Hi All I have the following redirect setup and it seems to work aprt form when the $ character is inserted into the rule. when HTTP_REQUEST { if { [HTTP::host] equals "www.thiswebsite.com" and [HTTP::uri] starts_with "/t/$1" } { HTTP::redirect "http://www.thiswebsite2.com/www.thiswebsite.com/t/$1" } } The problem however is that the virtual server responds with a receive failure. There is something about the $ that the F5 VS doesnt like. Any pointers would be appreciatedSolved400Views0likes5CommentsHTTP redirect when Path is / and host is not FQDN
I wrote a simple irule to do HTTP redirect: when HTTP_REQUEST { if { !([string tolower [HTTP::host]] ends_with "mycompany.com") } { append [HTTP::host] "mycompany.com" } if { [HTTP::path] eq "/" or [HTTP::path] eq "" } { HTTP::redirect "http://application.mycompany.com/ABC" } } I expect my iRule to redirect: http://application/ or http://application.mycompany.com/ to http://application.mycompany.com/ABC But it is not the case, the iRule is not doing anything when host is not FQDN and it seems the condition evaluation doesn't work for empty path (/)380Views0likes1CommentiRule 404 redirect with original URL in URL bar
Hi. Sorry for asking but I cannot find a complete answer for this. If a user browses to an invalid URL (e.g. https://www.example.com/invalidurl), I would like the iRule to redirect to a separate 404 webpage (e.g. https://www.example.com/404.html) but contain the original URL in the URL bar - i.e. the redirect to https://www.example.com/404.html is not visible to the user. There are examples that redirect ok but the 404 URL is still visible to the user. Any advice please?292Views0likes0Commentsredirect based on source ip subnet to another website.
hi all, I am working with irule and it would work find when HTTP::redirect "http://www.google.com[HTTP::uri]" with reject, however I am not even able to save it the way it is below. when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals DataGroupList] } { HTTP::redirect "http://www.google.com[HTTP::uri]" } } can anyone tell me what am I doing wrong? or better, tell me what to do so that this irule would work? all comments and replies are much appreciated. MJ340Views0likes3CommentsHow to set up http 301 response
Here is my problem. Our web server administrator has a website: which is currently hosted by a vendor they will no longer use once the site is retired. He is going to make a new site called hosted by a different vendor. When siteB is ready they want siteA to return a 301 redirect to siteB. They do not want to do this usign the site A vendors server. They also do not simply want to point the DNS for siteA.company.com to the same server as siteB using an A record or a CNAME record. A 301 redirect is their preference so that search engines will be updated. Is this possible to do on the F5 LTM? If I set up a virtual server, point the DNS entry for SiteA at the virtual server, and then have the F5 redirect the users to siteB? I know this would be fairly simple to do using an apache web server but I would prefer to use the F5 so that I don't have to provision a web server just to do a redirect. I am having a hard time figuring out the syntax that would be needed to do this with an irule. My searches into this question have so far turned up conflicting and unclear answers. If this is possible, can someone please explain it to me using the example names above? Thanks.Solved1.1KViews0likes4Comments