For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Gilles_Archer_3's avatar
Gilles_Archer_3
Icon for Nimbostratus rankNimbostratus
Sep 30, 2013

How to redirect user to URL based on entered CNAME

I apologize if this has been asked and answered in the past, but I'm not sure which keywords I should be using to find what I'm looking for.

 

What I'm trying to do is when a user enters 'service-a' in a browser, we want the GTM to direct the user to "http://service-a.company.com". If they enter 'service-b' in the browser, we want to direct them to "http://service-a.company.com/service-b".

 

Can this be solved with just an iRule on the GTM? Or is this mostly an LTM solution?

 

Thanks everyone.

 

1 Reply

  • Just a thought, but the first issue is generally resolved with a CNAME. I don't believe GTM can natively issue a CNAME from a given short name, so an iRule like this (applied to the LTM listener VIP) could work. This is a very simple example, so I'm sure there's a better way.

    when DNS_REQUEST {
        switch [string tolower [DNS::question name]] {
            "service-a" {
                DNS::answer insert "service-a CNAME service-a.company.com"
                DNS::return
            }
            "service-b" {
                DNS::answer insert "service-b CNAME service-b.company.com"
                DNS::return
            }
        }
    }
    

    Where "service-a.company.com" and "service-b.company.com" resolve to the same virtual server IP. Then use an iRule on the VIP that validates the Host header:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "service-b.company.com" } {
            HTTP::redirect "http://service-a.company.com/service-b"
        }
    }