Forum Discussion
Hi All,
Thanks for you replies. I suspect from the internal server doing this redirection but i do not know exact reason.
I will check more detail and inform you.
Hi Kevin by the way, there is a redirection irule on VIP like ;
if [HTTP::uri] equals "/" do HTTP::redirect "/blabla"
Regards,
- Kevin_Davies_33Oct 19, 2017Nimbostratus
Its pretty standard for most appplication to have redirects of some sort. The F5 can remap the destination using that setting in HTTP profile.
- Seckin_149390Oct 20, 2017Nimbostratus
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.
- Kevin_Davies_33Oct 20, 2017Nimbostratus
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]" } } }
- Stanislas_Piro2Oct 20, 2017Cumulonimbus
Hi kevin,
in the example below, the url is:
https://bgmdvfiop1.internal.borusan.com/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html
with your irule, the location will be :
/sap
because getfield will return only 4th field, not following fields.
and in the example, you can see it is a POST which means this is not from a 302 response. when I tried to connect, I received 307 status code.
- Kevin_DaviesOct 21, 2017MVP
Thank you Stanislas. What it should have been ...
when HTTP_RESPONSE { if {[HTTP::status] eq 302} { if {[HTTP::header Location] starts_with "http"} { HTTP::header replace Location "/[join [lrange [split [HTTP::header Location] {/}] 3 end] {/}]" } } }
- Stanislas_Piro2Oct 21, 2017Cumulonimbus
Kevin,
when server send redirect, the location header can be:
- absolute URL of the redirect resource on the same server (ex : https://bgmdvfiop1.internal.borusan.com/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html)
- 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)
- Kevin_DaviesOct 23, 2017MVP
I have updated the iRule.
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 } } } }
- Stanislas_Piro2Oct 23, 2017Cumulonimbus
Kevin,
Try your first Irule with location header
😉https://bgmdvfiop/
- Kevin_DaviesOct 23, 2017MVP
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.
- Stanislas_Piro2Oct 23, 2017Cumulonimbus
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]] } }