Forum Discussion
Getting Started with iRules: Intro to Programming with Tcl
Hi Dario,
Sorry to be base level, but when using that syntax :
- when HTTP_REQUEST {
- set url "https://[getfield [HTTP::uri] "URL=" 2]"
- set host [URI::host $url]
- set path [URI::path $url]
- set basename [URI::basename $url]
- HTTP::uri $path$basename
- HTTP::host $host
- }
Which pool is triggered? A pool that I need to define as www.xyz.com ?
Thank you
Stephane
- Dario_GarridoOct 22, 2020
Noctilucent
Hello.
In my case, the pool was configured directly into the VS, but it's also possible to do it in the iRule.
REF - https://clouddocs.f5.com/api/irules/pool.html
There you have examples of how to select pools base on URI.
Regards,
Dario.
Hi Dario,
Thank you for you answer.
Unfortunatly, I can't use a pool. That www.def.com/ghi was an example. I should be able to process anything, as a wildcard, that comes after URL= . Our software developers need to be able to put in any address they need after URL= without having to notify the F5 admin.
Thank you
Stephane
- Dario_GarridoOct 21, 2020
Noctilucent
Hello Strich.
Using a pool is relatively easy. With this iRule I'll have everything working properly
when HTTP_REQUEST { set url "https://[getfield [HTTP::uri] "URL=" 2]" set host [URI::host $url] set path [URI::path $url] set basename [URI::basename $url] HTTP::uri $path$basename HTTP::host $host }
If I test it with curl I've got this:
# CUSTOMER REQUEST TO BIG-IP GET /URL=www.wyz.com/app HTTP/1.1 User-Agent: curl/7.19.7 Accept: */* Host: www.abc.com # BIG-IP REQUEST TO BACKEND GET /app HTTP/1.1 User-Agent: curl/7.19.7 Accept: */* Host: www.wyz.com
If you don't want to specify a pool in order to use it for a generic purpose then you need to include more logic in that iRule. One possible way to get your goal is to construct a sideband connection.
Try it, but from my perspective, it's better to configure an Access Portal using APM instead of configure that with an iRule. The URL structure is going to be slightly different, but it will be easier to configure it.
This is the URL structure using an Access Portal:
www.abc.com/f5-w-<HEX_equivalent_of_backend_FQDN>$$/uri
If this was helpful, please don't forget to mark my answer as "the best" to help me for the contribution.
Regards,
Dario.
- Dario_GarridoOct 21, 2020
Noctilucent
Hello.
"www.def.com" should be configured as a pool member resource.
You can use a rewrite profile or just modify the irule to replace these specific headers:
GET /URL=www.def.com/ghi HTTP/1.1
Host: www.abc.com
To get this:
GET /ghi HTTP/1.1
Host: www.def.com
If "www.def.com" page has references to relative path resources (let say href="/images/myimage.png") you should take this into account replacing the payload during the HTTP_RESPONSE.
Besides of URI and host header, there exist other headers that could need to put an eye of them.
- Cookies
- Content-Security-Policies
- Etc
The best option is to connect the backend resource directly (with browser inspector) and try to investigate how your site is in order to plan your scope.
Regards,
Dario.