Forum Discussion

soda0091_86320's avatar
soda0091_86320
Icon for Nimbostratus rankNimbostratus
Apr 26, 2013

Irule adding dns FQDN + appending url

 

I am using the iRule below to append a url to a VIP that is defined on our F5. Currently the output comes out as DNSshortname/url/url2. Our end user has requested that the URL show up using the fully quantified name. Can it be done so that the URL shows up using the fully qualtified name in the end users browser?

 

Example

 

So currently.

 

DNS/url/url2

 

Would like to change to below so that the full path is seen in the end users browser.

 

DNS.mydomain.com/url/url2

 

iRule in use

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] equals "/") } {

 

HTTP::uri /page/page2[HTTP::uri]

 

}

 

}

 

4 Replies

  • you may use HTTP::redirect.

    HTTP::redirect wiki

    https://devcentral.f5.com/wiki/iRules.http__redirect.ashx

    e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
      if { [HTTP::host] equals "DNS" and [HTTP::uri] equals "/" } {
        HTTP::redirect "http://DNS.mydomain.com/url/url2/"
      }
    }
    }
    [root@ve10:Active] config  curl -I http://172.28.19.252/ -H "Host: DNS"
    HTTP/1.0 302 Found
    Location: http://DNS.mydomain.com/url/url2/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • Thank you for the response. Can you explain what the code is doing so that I have a better understanding?

     

     

    Thanks.

     

  • Can you explain what the code is doing so that I have a better understanding?it does http redirection when http host header is DNS and uri is /.

     

     

    more information about url and http redirection can be found in the following links.

     

     

    5-Minute iRules: What’s a URL? by Jason Rahm

     

    https://devcentral.f5.com/blogs/us/5-minute-irules-what-rsquos-a-url

     

     

    Redirects, Rewrites and App Transfers via iRules by Colin Walker

     

    https://devcentral.f5.com/tech-tips/articles/redirects-rewrites-and-app-transfers-via-irules