We have a customer and they have interesting issue on their application side.
When we send a http request to the VIP, firstly related hostname appears in the browser then 2-3 seconds later hostname turns into server internal name which is unwanted case for customer.
The problem is we don’t know if the server returns the external name in redirect only or in all http response links.
The best solution is to look at the server configuration if you can set the external url. Most of http server support it and it will increase f5 performances instead of irule inspecting all response pages.
If you’re unsure what’s being sent back from the backend, run a tcpdump from the command line, and capture to a file (-w option), grabbing the full packet (-s 0 == don’t truncate the snap) and then peruse the response either via tcpdump, or if you’re more desktop orientated using something like wireshark
Often seeing exactly what is coming back can be a good hint as to why it’s doing that
We have 2 VIPs, first one is http VIP and used for only https redirection works ok. Second one is https and SSL offlading comes here. Also, there is a irule on https VIP to redirect another path comes from client which works ok too ;
when HTTP_REQUEST { if { [HTTP::path] equals “/” } { HTTP::redirect “/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html” } }
This is the Client, F5 and Server connection ;
Client <-----> F5 (HTTPS, Redirect IRule) <-----> Server (HTTP, 8000)
Hi Kevin, yeah it’s maybe from the application but i need to fix this one. From your previous answer, you were mention about Redirect Rewrite but issue is not related to http to https redirect.
If that does not help you then you can try the following simplified code to solve your problem. This will ensure that all redirects relative. This takes http://mylocal.server.com/anyway?hello=1 and makes it /anyway?hello=1. This means it will not longer change the name of the server in the browser.
when HTTP_REQUEST {
if {[HTTP::status] eq 302} {
if {[HTTP::header Location] starts_with "http"} {
HTTP::header replace Location "/[getfield [HTTP::header Location] {/} 4]"
}
}
}
absolute URL of the redirect resource on different server (ex: http://www.f5.com/)
relative URL of the redirect resource with absolute path (ex : /sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html)
relative URL of the redirect resource with relative path (ex : ../abap/FioriLaunchpad.html)
trying to solve this with a split will be difficult : - this solve the first type - this may cause issues for the second type. if there is a redirect to an external host, don’t replace the location header) - relative URLs will lead to not found pages.
best solutions are
scan
string map
and you missed the 307 code (I have to correct my code above too)
when HTTP_RESPONSE {
if {[HTTP::status] starts_with 30} {
if {[HTTP::header Location] starts_with "https://bgmdvfiop"} {
HTTP::header replace Location "/[join [lrange [split [HTTP::header Location] {/}] 3 end] {/}]"
}
}
}
This covers all the cases you mentioned. If I was to use the scan you mentioned… it would be as follows. Would have to test the CPU cycle count for each to see which is more efficient.
when HTTP_RESPONSE {
if {[HTTP::status] starts_with 30} {
if {[scan [HTTP::header Location] {%[^:]://%[^/]%s} aproto ahost auri] == 3} {
if {$ahost starts_with "bgmdvfiop"} {
HTTP::header replace Location $auri
}
}
}
}
The solution is appropriate for the client requirement. The server names are known and we are not dealing with unknown elements. Being overly specific is wasteful of resources. iRules are designed to deal with specific use cases and be efficient in achieving the desired outcome.
iRules are designed to deal with specific use cases and be efficient in achieving the desired outcome.
I agree but you must make sure the solution won’t cause issues.
I think the best solution is :
when HTTP_RESPONSE {
if { [HTTP::status] matches "30?"} {
replace the internal URL to / with or without / ant the end of the path
HTTP::header replace Location [string map {"https://bgmdvfiop1.internal.borusan.com/" "/" "https://bgmdvfiop1.internal.borusan.com" "/"} [HTTP::header Location]]
}
}