Hostname turns into server internal name

Hi Everyone,

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.

Is there any way to prevent this stuation ?

Regards,

If you open developer tools in the browser do you see a 302 redirect? If you do, what is the value for Location?

Sounds like a redirect by the internal server. You can configure redirect rewrites to take care of that

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.

Create a HTTP profile, enable Redirect Rewrites to All.

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,

Its pretty standard for most appplication to have redirects of some sort. The F5 can remap the destination using that setting in HTTP profile.

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

Hi,

Here is the full description ;

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)

By the way, this is SAP application.

Some test from browser checking headers ;

  1. Request URL: https://bgmdvfiop1.internal.borusan.com/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html
  2. Request Method: POST
  3. Status Code: 200 OK
  4. Remote Address: 10.10.37.96:443
  5. Referrer Policy: no-referrer-when-downgrade
  6. Response Headersview source
  7. cache-control: no-cache, no-store
  8. content-encoding: gzip
  9. content-length: 5937
  10. content-type: text/html; charset=utf-8
  11. expires: 0
  12. pragma: no-cache, no-store, private
  13. set-cookie: sap-login-XSRF_MFP=20171019122612-50hLB1TbswKM3cngRpnojg%3d%3d; path=/; HttpOnly
  14. set-cookie: sap-usercontext=sap-language=TR&sap-client=400; path=/
  15. Request Headersview source
  16. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
  17. Accept-Encoding: gzip, deflate, br
  18. Accept-Language: tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4
  19. Cache-Control: no-cache
  20. Connection: keep-alive
  21. Content-Length: 291
  22. Content-Type: application/x-www-form-urlencoded
  23. Host: bgmdvfiop1.internal.borusan.com
  24. Origin: https://bmgsfiori.borusan.com
  25. Pragma: no-cache
  26. Referer: https://bmgsfiori.borusan.com/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html
  27. Upgrade-Insecure-Requests: 1
  28. User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

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.

You provided the real URL, so I tried to look at it and it seems there is no internal or external hostname reference, all URLs are relative.

did you enable the irule I provided?

Do you still have the issue?

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]"
        }
    }
}

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.

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] {/}]"
        }
    }
}

Kevin,

when server send redirect, the location header can be:

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)

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
            }
        }
    }
}

Kevin,

Try your first Irule with location header

https://bgmdvfiop/

:wink:

Hi Stanislas,

Related service is not on production and we will try this one by using hosts file on windows, i will try today and inform you. Many thanks for your

Best regards

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]]
    }
}