Forum Discussion

N__197982's avatar
N__197982
Icon for Nimbostratus rankNimbostratus
Oct 02, 2017

iRule tp detect HTTP and TCP requests and then do some magic.

I have an iRule working fine which takes an http hostname, strips the external domain name and then appends internal domain name. The F5 does a lookup for this internal domain name and sets the resolved IP address as the member for the VIP. All this works fine with the F5 doing it's magic for http requests

 

Now the requirement is to support a normal TCP connection in the same iRule which may not be an http request. I did some checks and seen that we can collect the TCP::request for the initial bytes. Any suggestion how the incoming hostname can be captured in that? The incoming hostname would be something like xxx-xxx-xxxx.externaldomain.com.

 

Futher will the HTTP and the TCP be supported in the same iRule?

 

  • Hi,

     

    There is no magic, LTM knows how to decode HTTP protocol and allow to read headers.

     

    Do you know what application you want to manage like HTTP? If yes, you can decode it to read hostname (if exists, it’s not sure) and forward tcp connection to internal host.

     

  • In addition to what Stanislas said, also note that with your existing iRule, you are using http commands and events which means that you have an http profile on your Virtual Server. What the profile does is it makes the BIG-IP parse http headers, which means that the traffic must conform to some base minimum of the http standard. That in turn means that traffic that isn't http going through that Virtual Server will fail, since the BIG-IP will drop non-http traffic. So it's unlikely that you will be able to handle both types of traffic on the same Virtual Server.

     

    Supposedly there's a way around that by creating a http profile that uses transparent as the proxy type, but I haven't played around too much with that so I'm not sure how well that actually works.

     

    • N__197982's avatar
      N__197982
      Icon for Nimbostratus rankNimbostratus

      Here is what I managed to work on. I will be setting a static port for this custom TCP application to run. The HTTP iRule can run as it is to work on present requests.

       

      The iRule I worked on is:

       

      when CLIENT_ACCEPTED { log local0.debug "CLIENT_ACCEPTED" TCP::collect 50 } when CLIENT_DATA { if { [TCP::payload 50] contains "external.com" }

       

      Now, I want to capture that name which is before the external.com and take that in a variable. Then do a lookup using that name and appending internal.com.

       

      After that take that name.internal.com and set the resolved IP address as the pool member

       

      any comments?

       

    • Henrik_Gyllkran's avatar
      Henrik_Gyllkran
      Icon for Nimbostratus rankNimbostratus

      Yeah, I would use a stream expression to deal with rewriting the data, since you can't use HTTP commands. Have a look at the STREAM::expression syntax for some examples.

       

    • N__197982's avatar
      N__197982
      Icon for Nimbostratus rankNimbostratus

      in this case the stream before the .external.com will have to be queried. How can that be done?