Dear Friends,
I need a help on a rewrite iRule. The condition as follows…
x.y.com/EBC rewrite to x.y.com/ebc
x.y.com rewrite to x.y.com/ebc
I would appreciate if anyone can shed some light on this iRule requirement.
Thanks in advance.
Dear Friends,
I need a help on a rewrite iRule. The condition as follows…
x.y.com/EBC rewrite to x.y.com/ebc
x.y.com rewrite to x.y.com/ebc
I would appreciate if anyone can shed some light on this iRule requirement.
Thanks in advance.
e.g.
configuration
[root@ve11c:Active:In Sync] config tmsh list ltm virtual bar
ltm virtual bar {
destination 172.28.24.10:80
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 8
}
[root@ve11c:Active:In Sync] config tmsh list ltm pool foo
ltm pool foo {
members {
200.200.200.101:80 {
address 200.200.200.101
}
}
}
[root@ve11c:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
switch [HTTP::uri] {
"/" -
"/EBC" {
HTTP::uri "/ebc"
}
}
}
}
test1
[root@ve11c:Active:In Sync] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(39714) <-> 172.28.24.10(80)
1457237630.7187 (0.0016) C>S
---------------------------------------------------------------
GET /EBC HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.14(39714) <-> 200.200.200.101(80)
1457237630.7230 (0.0041) C>S
---------------------------------------------------------------
GET /ebc HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
test2
[root@ve11c:Active:In Sync] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(39715) <-> 172.28.24.10(80)
1457237660.4237 (0.0026) C>S
---------------------------------------------------------------
GET / HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.14(39715) <-> 200.200.200.101(80)
1457237660.4253 (0.0014) C>S
---------------------------------------------------------------
GET /ebc HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
The external clients will hit the LTM with a own http host “x.y.com/EBC” and “x.y.com” we do need to “rewrite” this requests that the webserver understands it: “x.y.com/ebc”.
firstly, here is short video explaining about HTTP::host and HTTP::uri.
5-Minute iRules: What’s a URL? by Colin Walker
Do we need to use “string tolower” command in the beginning
there are several ways to change letter case. string tolower is a good choice when you want to change whole string no matter what the string is.
if you want to change specific string, string map might be a better choice.
e.g.
configuration
[root@ve11c:Active:In Sync] config tmsh list ltm virtual bar
ltm virtual bar {
destination 172.28.24.10:80
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 8
}
[root@ve11c:Active:In Sync] config tmsh list ltm pool foo
ltm pool foo {
members {
200.200.200.101:80 {
address 200.200.200.101
}
}
}
[root@ve11c:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
HTTP::uri [string map -nocase {/ebc /ebc} [HTTP::uri]]
}
}
test1
[root@ve11c:Active:In Sync] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(39724) <-> 172.28.24.10(80)
1457248223.0429 (0.0026) C>S
---------------------------------------------------------------
GET /Ebc HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.14(39724) <-> 200.200.200.101(80)
1457248223.0470 (0.0018) C>S
---------------------------------------------------------------
GET /ebc HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
test2
[root@ve11c:Active:In Sync] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(39725) <-> 172.28.24.10(80)
1457248251.3621 (0.0016) C>S
---------------------------------------------------------------
GET /EBC HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.14(39725) <-> 200.200.200.101(80)
1457248251.3639 (0.0015) C>S
---------------------------------------------------------------
GET /ebc HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
test3
[root@ve11c:Active:In Sync] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(39726) <-> 172.28.24.10(80)
1457248276.1222 (0.0014) C>S
---------------------------------------------------------------
GET /EBC/BHAbhaBHA HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.14(39726) <-> 200.200.200.101(80)
1457248276.1239 (0.0015) C>S
---------------------------------------------------------------
GET /ebc/BHAbhaBHA HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: x.y.com
---------------------------------------------------------------