Forum Discussion

LyonsG_85618's avatar
LyonsG_85618
Icon for Cirrostratus rankCirrostratus
Mar 15, 2012

Redirect IRULE

Looking for a bit of help please guys...

 

 

I am trying to write an IRULE that rewrites the host and uri but without doing a re-direct to clients browser.

 

 

when HTTP_REQUEST

 

if {[HTTP::host] equals "www.company.com" && [HTTP::uri] equals "/application"} {

 

HTTP::header replace Host "www.newcompany.com"

 

HTTP::uri /full/application/is/here

 

virtual VS_THIS_IS_WHERE_NEW_COMPANY_IS_CONFIGURED

 

}

 

}

 

 

The new virtual server where traffic is getting routed to does have client & server SSL profiles configured.

 

 

Both virtual servers (for old & new company) work fine.

 

 

I think I am missing something obvious but just can't see it.....

 

 

Thanks in advance for your help!

 

 

 

 

6 Replies

  • i think you have to use pool command (to new company pool) instead of virtual command.
  • Nitass....thanks for reply. I have tried pool command too.

     

    Doing some further testing I have managed to get the syntax working on an internal BIG-IP.

     

    The rules above is defined on BIG-IP's behind firewalls. I am now thinking (perhaps)

     

    the firewall rules are not set correctly?
  • the firewall rules are not set correctly?i do not think so. i understand virtual command will send traffic to VS_THIS_IS_WHERE_NEW_COMPANY_IS_CONFIGURED internally (within bigip). so, firewall should not matter.

     

     

    what i think is host header and uri might not be changed when sending to VS_THIS_IS_WHERE_NEW_COMPANY_IS_CONFIGURED.
  • sorry i am wrong.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            log local0. "\[HTTP::host\]: [HTTP::host]"
            log local0. "\[HTTP::uri\]: [HTTP::uri]"
    
            HTTP::header replace Host "www.abc.com"
            HTTP::uri "/abc"
            virtual bar102
    }
    }
    [root@ve1023:Active] config  b virtual bar102 list
    virtual bar102 {
       snat automap
       pool foo102
       destination 1.1.1.1:80
       ip protocol 6
       rules myrule102
       profiles {
          http {}
          tcp {}
       }
       vlans none enable
    }
    [root@ve1023:Active] config  b rule myrule102 list
    rule myrule102 {
       when HTTP_REQUEST {
            log local0. "\[HTTP::host\]: [HTTP::host]"
            log local0. "\[HTTP::uri\]: [HTTP::uri]"
    }
    }
    
    [root@ve1023:Active] config  curl -I http://172.28.19.79
    HTTP/1.1 404 Not Found
    Date: Thu, 15 Mar 2012 14:34:10 GMT
    Server: Apache/2.2.3 (CentOS)
    Content-Type: text/html; charset=iso-8859-1
    
    [root@ve1023:Active] config  cat /var/log/ltm
    Mar 15 07:40:03 local/tmm info tmm[4797]: Rule myrule : [HTTP::host]: 172.28.19.79
    Mar 15 07:40:03 local/tmm info tmm[4797]: Rule myrule : [HTTP::uri]: /
    Mar 15 07:40:03 local/tmm info tmm[4797]: Rule myrule102 : [HTTP::host]: www.abc.com
    Mar 15 07:40:03 local/tmm info tmm[4797]: Rule myrule102 : [HTTP::uri]: /abc
    
  • what exactly is the issue now? i don't see what fails ...

     

     

    how you tried with tcpdump to see where to traffic goes?
  • Thanks for help.

     

    Looks like the problem was that there was another IRULE on the virutal server.

     

    I added "event disable all" to end of this IRULE and traffic is now hitting the other virtual server.

     

     

    Many thanks