Forum Discussion
Need help on rewrite iRule
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
https://devcentral.f5.com/videos/5-minute-irules-whats-a-urlDo 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
---------------------------------------------------------------
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com