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

ljk8254's avatar
ljk8254
Icon for Nimbostratus rankNimbostratus
Nov 23, 2011

url uri redirection or rewrite

Hi iRules gurus,

 

 

I am a very new for iRules...but I have to implement and solve an internal request.

 

Unfortunately, I do not have much knowledges regarding the iRules.

 

 

What I need to do is that

 

- if the request comes in to https://aaa.com/testing then set up to direct connections to either of these two:

 

- https://bbb.com/go/testing

 

- https://ccc.com/go/testing

 

 

In that case, how can I make a script to meet the requirement?

 

I really appreciate it if you can advise and save me...

 

 

Thanks in advance.

 

Jake

 

 

 

1 Reply

  • not sure if i understand correctly or not. this is an example. i used http instead of https because it is a bit easier to display http header.

    [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 pool foo list
    pool foo {
       members {
          200.200.200.101:80 {}
          200.200.200.102:80 {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            if {[string tolower [HTTP::host]] equals "aaa.com"}{
                    if {[string tolower [HTTP::uri]] starts_with "/testing"}{
                            HTTP::uri "/go[HTTP::uri]"
                    }
            }
    }
    
    when HTTP_REQUEST_SEND {
            clientside {
                    HTTP::header replace Host [class match -value [LB::server addr] equals ip_to_host]
            }
    }
    }
    [root@ve1023:Active] config  b class ip_to_host list
    class ip_to_host {
       {
          "200.200.200.101" { "bbb.com" }
          "200.200.200.102" { "ccc.com" }
       }
    }
    
    1
    
    [root@ve1023:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.253(45217) <-> 172.28.19.79(80)
    1322052891.8574 (0.0022)  C>S
    ---------------------------------------------------------------
    HEAD /testing/abc HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5
    Host: aaa.com
    Accept: */*
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(45217) <-> 200.200.200.101(80)
    1322052891.8582 (0.0007)  C>S
    ---------------------------------------------------------------
    HEAD /go/testing/abc HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5
    Host: bbb.com
    Accept: */*
    ---------------------------------------------------------------
    
    2
    
    [root@ve1023:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.253(45219) <-> 172.28.19.79(80)
    1322052913.8332 (0.0021)  C>S
    ---------------------------------------------------------------
    HEAD /testing/abc HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5
    Host: aaa.com
    Accept: */*
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(45219) <-> 200.200.200.102(80)
    1322052913.8344 (0.0011)  C>S
    ---------------------------------------------------------------
    HEAD /go/testing/abc HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5
    Host: ccc.com
    Accept: */*
    ---------------------------------------------------------------