Forum Discussion

dihris_116090's avatar
dihris_116090
Icon for Nimbostratus rankNimbostratus
Oct 26, 2015

iRule for URL rewriting

Hi All,

 

I have a query on URL rewriting. Here is the scenario:

 

abc.externalurl.com/something/action?key1=value1 --> F5 --> something.internalurl.com/action?key1=value1

 

secondhost.com is internal URL not available to the public, so I think it should be host replacement rather than redirect.

 

6 Replies

  • Maybe something like this:

    when HTTP_REQUEST {
       set val1 [getfield [HTTP::uri] "/" 1]
       set val2 [getfield [HTTP::uri] "/" 2]
       set my_location "$val1.internalurl.com/$val2"
       HTTP::Respond 301 Location "$my_location"
       log local0. "Redirecting to $my_location"
    }
    

    Cheers.

  • Sorry - I missed the "http://" on the redirect.

    set my_location "http://$val1.internalurl.com/$val2"
    
  • Does the iRule change if the VS is HTTPS ? Also as the internalurl.com should be visible to the end user will the iRule take care for the http_respond back and remap the respond back to abc.externalurl.com?

     

    The reason I had in mind iRule is that it's more flexible and adding another context later would not be a problem. Where with clientside/serverside rewrite profile is static.

     

    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus
      The ltm does not select destination server base on his hostname. you must create one pool for each internal server. so you must change configuration for each new internal service to publish and assign it to the external URL.
  • Sorry - I made a typo. "... as the internalurl.com should NOT be visible to the end user will the iRule take care for the http_respond back and remap the respond back to abc.externalurl.com?"