Forum Discussion

wowchens's avatar
wowchens
Icon for Nimbostratus rankNimbostratus
Nov 24, 2008

Host Header based Routing

Hello: I have a unique(not sure if its unique) requirement with a bunch of my web sites. I am trying to host like 5 externally facing websites using ONE external IP Address. I am wondering to see if there is an IRule that I can use to differentiate requests based on host headers, instead of using a separate IP for each one of them. These sites are very simple html informational ones.

 

 

Can someone please help with me with an IRule or something.

 

 

Thanks,

 

Chenna

5 Replies

  • This is what I got my sites working. Please let me know your expert thoughts on this.

     

    when HTTP_REQUEST {

     

     

    switch [string tolower [HTTP::host]] {

     

    www.domain1.com { pool domain1 }

     

    www.domain2.com { pool domain2 }

     

    default { discard }

     

    }

     

     

    }
  • That looks great. If you are on 9.4 or higher, you could also use HTTP classes to do this. But the iRule looks fine.

     

     

    Aaron
  •  

    I am facing this as well. In addtion, what would be the oder of operatiosn for a vip that needs multiple irules? I need to redirectt http to https and route based on host header?
  • One note, this does not work with SSL sites, since you can't invoke the iRule before doing the SSL handshake, so unless you have a wildcard cert, you will get hostname mismatches in the browser.

     

     

    The order of operation of iRules should be in the order they are listed in the GUI. There was a bug about this in earlier versions of 9.x, not sure exactly when it got fixed.

     

     

    Denny
  • Posted By steve_j on 02/02/2009 8:08 AM

     

    I am facing this as well. In addtion, what would be the oder of operatiosn for a vip that needs multiple irules? I need to redirectt http to https and route based on host header?

     

     

     

    You can also use iRule priority to control which rules are processed first.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/priority.html

     

     

    So you could have your http->https rewrite with a higher priority (so it runs first) followed by a second rule with a lower priority to do the per-domain filtering.