Forum Discussion

Jaime_Flores's avatar
Jaime_Flores
Icon for Nimbostratus rankNimbostratus
Mar 07, 2018

HTTP 2 HTTPS redir with internal and external URL's

Hi.

I'm having problems with a HTTP to HTTPS redirect for a especific VirtualServer. I explain the situation:

We have a F5 LTM that only works with internal URL's, and a reverse proxy that handles external URLs and sends them to F5. My site has both external and internal URL's (http://internal.myapp.com/site/myapp & http://externaldomain.com/site/myapp). Now, all works well with HTTP protocol, but the problem comes with the HTTP2HTTPS redirect. I'm using a simple iRule like this:

  when HTTP_REQUEST {
    HTTP::respond 301 Location "https://externaldomain.com[HTTP::uri]"
  }

  With internal URL we have no problem, I request http://internal.myapp.com/site/myapp and the F5 respond with https://internal.myapp.com/site/myapp (our DNS do the hard job). The problem is when I request the external URL, because the response is the internal URL: I request http://externaldomain.com/site/myapp and the response is https://internal.myapp.com/site/myapp. However, if I use the next iRule (with the URI hardcoded), all works fine:

  when HTTP_REQUEST {
    HTTP::respond 301 Location "https://externaldomain.com/site/myapp"
  }

The question is: Why have I to put the complete URL?? Why the [HTTP::uri] var is not working??

Thanks for your response.

1 Reply

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    You can just use the built-in irule "_sys_https_redirect", or copy it into your own irule, if you do not intend it to apply globally.

     

    [EDITED]