Load Balance 4 URI over 2 IPs and rewrite http response location
I have been struggling with this and I hope someone can assist. The challenge is twofold: 1. Need Virtual Server to load balance between 4 URIs which are spread over 2 Nodes. 2. When the webservers respond, they respond with a location which points to itself instead of the FQDN the client specified I have tried solving with numerous variations of below iRules, but fail when the client receives the Nodes http://hostname:portnumber/URi/web2.exe (which isn't reachable from client network). @1:Irule to load balance between 4 URIs: Virtual Server name: vs_example.com IP: 172.16.0.1 b. Pools: pool_example1-uri-1_81 - node_01_10.0.0.1:81 pool_example1-uri-2_81 - node_01_10.0.0.1:81 pool_example2-uri-3_81 - node_02_10.0.0.2:81 pool_example2-uri-4_81 - node_02_10.0.0.2:81 c. iRule: when HTTP_REQUEST { # Check if the requested URI is either / or /CAisd/pdmweb.exe if { [HTTP::uri] eq "/" or [HTTP::uri] eq "/CAisd/pdmweb.exe" } { # Define the possible URIs and corresponding pools set uri_pool_map { /URi/web1.exe pool_example1-uri-1_80 /URi/web2.exe pool_example1-uri-2_80 /URi/web3.exe pool_example1-uri-3_80 /URi/web4.exe pool_example1-uri-4_80 } # Initialize a list of available pools set available_uri_pool_list {} # Check the availability of each pool and add to the list if available for {set i 0} {$i < [llength $uri_pool_map]} {incr i 2} { set pool_name [lindex $uri_pool_map [expr {$i + 1}]] if {[active_members $pool_name] > 0} { lappend available_uri_pool_list [lindex $uri_pool_map $i] $pool_name } else { log local0. "Pool $pool_name is not available" } } # If no pools are available, send an error response if {[llength $available_uri_pool_list] == 0} { HTTP::respond 503 content "Service Unavailable - No available pools" return } # Select the next URI and corresponding pool in a round-robin fashion from available pools set index [expr {[clock clicks -milliseconds] % ([llength $available_uri_pool_list] / 2)}] set next_uri [lindex $available_uri_pool_list [expr {$index * 2}]] set next_pool [lindex $available_uri_pool_list [expr {$index * 2 + 1}]] # Log the selected URI and pool for troubleshooting log local0. "Selected URI: $next_uri, Pool: $next_pool" # Replace the URI with the selected one HTTP::uri $next_uri # Select the corresponding pool pool $next_pool } } @2. iRule to replace location in HTTP Response when HTTP_RESPONSE_RELEASE { if { [HTTP::header exists "Location"] } { set location [HTTP::header "Location"] log local0. "Original Location header: $location" # Modify the Location header if it contains the internal server reference if { $location starts_with "http://webserver1" || $location starts_with "http://webserver2" } { set new_location [string map { "http://webserver1:81" "https://172.16.0.1" "https://webserver1:81" "https://172.16.0.1" "http://webserver2:81" "https://172.16.0.1" "https://webserver2:81" "https://172.16.0.1" } $location] HTTP::header replace "Location" $new_location log local0. "Modified Location header: $new_location" } } }58Views0likes1CommentReverse Proxy Not Behaving
I am working on addinglearninglocker andxapi routes to the f5 reverse proxy and things are not behaving as I would have expected. The routes to Moodle and Keycloak are working but Learninglocker and Xapi are not. Below is what I see when trying to connect to the dashboard. The initial /lrs-dashboard connection is made but the corresponding connections fail. Here is what I'm trying to do: Is what I'm trying to do with learninglocker and xapi even doable?50Views0likes1Commentapm session variable from part of uri...
Hey all, I have a problem I need to solve. We have an application that uses a mobile app, the app does authentication with apm(local sp/external idp) through one browser and then accesses the the backend server in another session.. and the apm is not aware of that second one so it gerenrates a new login which fails and the app cannot login. The app passes a identification value the the urls which the app uses.. I want to do the same. Does anyone know or have any tips on how i can catch part of the uri (sort of like this https://test.com/sessionid=1234-5678-9101) that contains the sessionid and apply it to a session variable? /Kim96Views0likes3CommentsiRule for load balancing to different virtual server depending on the URI path
Hi Guys, I have three Virtual Server to be configured on our LTM's which are running on the version 15.1.7. One virtual server is facing to client (let say VS-A) and contains two virtual server (let say VS-B and VS-C) that should be load balance. VS-B and VS-C need to load balance on the VS-A but the incoming traffic should be clasify use the uri /path. The conditions like this: if the uri contains /aa, /bb, /cc will be forward and load balance to VS-B and VS-VS-C. I tried to make irules like this: when HTTP_REQUEST { if { [HTTP::uri] contains "/aa,/bb,/cc" } { virtual VS_B } else { virtual VS_C } } But the results is traffic from the client always going to the VS-B, so the load balancing doesn't have running. I don't know it can be configured with the iRules or not, since I am not an expert in writing the iRules can anyone suggest me with the iRules that helps working the VIP as mentioned above. Appreciate any kind your insight. Thanks632Views0likes7CommentsiRule with regex, change string inside URI for another one
Hello, I want to redirect ( http 301) this request domain.com/pl/_company-id/SOME_DIGITS New request should look like this: domain.com/_company-id/SOME_DIGITS/?language_code REGEX domain.com/pl/_company-id/(\d+) domain.com/_company-id/$1/?language_code So I need to match SOME_DIGITS string and put it after new URI + put another sting later Should I change SOME_DIGITS to variable and use it later ? How can I do it ? I've no idea how to achive this goal, please help if anyone knows. best regardsSolved638Views0likes2CommentsiRule Query String Match and Redirect
I seem to be having difficulty finding too much on this and maybe it is as simple as it is, I am looking to perform a URI match with a few particular query strings and redirect to another website if the request is found. I have found a few articles indicating using a datagroup but this seems a bit excessive for the task I am looking at. Example: https://www.thedomain.com/dir1/index.html?newpath=Name1 -> https://www.newdomain.com/dir1/index.html?newpath=Name1 Is this as simple as something like: when HTTP_REQUEST { if { ( [string tolower [HTTP::host]] equals "www.thedomain.com" ) and ( [string tolower [HTTP::uri]] ends_with "Name1" ) } { HTTP::redirect "http://www.newdomain.com[HTTP::uri]" } } Will the query string after the "?" be picked up and carried over with [HTTP::uri]?1.2KViews0likes3CommentsBIG-IP : iRule to route uri-forms for all hosts
F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi My BIG-IP is configued with virtual-servers specific to hostname : VIP-1 handles www.example1.com VIP-2 handles www.example2.com DNS routes www.example1.com to VIP-1 IP and www.example2.com to VIP-2 IP For all hostnames, I need to route certain uri-forms to a an alternate traffic-manager ( pool_alt_tm ). My idea is to create a single iRule and add it to VIP-1 and VIP-2. Here's my iRule : when HTTP_REQUEST { set route_to_alt_tm 0 switch -glob [string tolower [HTTP::uri]] { "/best-pool*" - "/best-bar*" - "/most-romantic*" { set route_to_alt_tm 1 } "/about/termsandconditions.html" - "/about/yourpersonalinfo.html" - "/about/rewards.html" { set route_to_alt_tm 1 } } if {$route_to_alt_tm} { pool pool_alt_tm event disable all } } Are there any potential problems with not explicitly checking that request host matches www.example1.com --or-- www.example2.com ? Any drawbacks to this approach ?580Views0likes7CommentsPortion of iRule not being processed
I have combined multiple iRules into one, however the 2nd portion of the rule is not working. I have confirmed using logging that the URI is being caught, however redirection is not taking place. I believe I may not be nesting switch statements correctly. I have commented which parts of the script are working, and which section is not. Can anyone point me in the right direction? when HTTP_REQUEST { These DO work if { ([HTTP::host] equals "olddomain.com") } { switch -glob [HTTP::host] { "/" { HTTP::redirect "http://newdomain.com" } default { HTTP::redirect "http://newdomain.com[HTTP::uri]" } } } These do NOT work switch -glob [string tolower [HTTP::host]] { "oldforum.olddomain.com" { Check the URI, set to lowercase switch [string tolower [HTTP::query]] { "TID=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=posts&t=[URI::query [HTTP::uri] TID]" return } "FID=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=topics&f=[URI::query [HTTP::uri] FID]" return } "C=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=forum&c=[URI::query [HTTP::uri] C]" return } } } These DO work "*newdomain.com" - "*olddomain.com" { switch -glob [string tolower [HTTP::uri]] { "/someuri" { HTTP::redirect "http://newdomain.com/path-to/page.aspx" return } "/someuri2" { HTTP::redirect "http://http://newdomain.com/path-to/page.aspx" return } } } } }685Views0likes25CommentsMODIFY URI WITH IRULE
Hi I need to help me with an Irule that doesn't change the URI that client send. when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/swscersalud*" { pool Pool_Consorcio_test HTTP::uri "/Services/Utility/certificacionSalud/WS/Implementation/Service.serviceagent/WSCERSALUDSoapEndpoint" } "/wsconadmo*" { HTTP::uri "/Services/Utility/OyS/WS/Implementation/WSCONADMO.serviceagent/OySSoapEndpoint" pool Pool_Consorcio_test_V2 } "/wscomeps*" { log local0. "Incio wscomeps[HTTP::uri]" pool Pool_Consorcio_test_V3 HTTP::uri "/Services/Utility/siam/WS/Implementation/WSSIAM.serviceagent" log local0. "Cambio wscomeps [HTTP::uri]" } "/wssispos*" { log local0. "Incio wsispos [HTTP::uri]" pool Pool_Consorcio_test_V4 HTTP::uri "/Services/Utility/serviciosAportes/WS/Implementation/WSSISPOS_ServiciosAportes.serviceagent" log local0. "Modifico wsispos [HTTP::uri]" } } } when HTTP_REQUEST_SEND { switch [LB::server addr] { "10.237.146.1" { clientside { HTTP::header replace Host "vmpesbserver:14005" } } "10.237.146.2" { clientside { HTTP::header replace Host "vmpesbserver2:14005" } } } } In adition i need that the Irule identify the server and modify the hostname, but if the client send "/swscersalud" the port is 14000, if the client send "/wsconadmo" the port is 14003, if the client send "/wscomeps" the port is 14004 and if the client send "/wssispos" the port is 14005. The LTM has version 10.2.4325Views0likes3CommentsSorry page redirect
Im trying to set up an iRule that will redirect traffic to an IIS server when there are no active pool members. I have the basics working. However the sorry page will only display properly the first time if there is a uri. If the user refreshes the page or tries a different uri they get a 404. when HTTP_REQUEST { if { [active_members [LB::server pool]] < 1} { HTTP::uri "/" pool /ESI/solr.erp-pool } } How would i configure this irule to apply every time the user refreshes the page or hits the url again?749Views0likes8Comments