Forum Discussion
how to insert Basic Authorization into http header while redirecting
Sample iRule with Loggings:
config tmsh list ltm rule SLOWROLL
ltm rule SLOWROLL {
when HTTP_REQUEST {
if { [HTTP::header exists X-SLOWROLL] and [HTTP::header X-SLOWROLL] equals "1" } {
node 10.29.100.20 80
set url [HTTP::header Host][HTTP::uri]
set vip [IP::local_addr]:[TCP::local_port]
foreach aHeader [HTTP::header names] {
log local0. "HTTP REQUEST HEADER $aHeader: [HTTP::header value $aHeader]"
}
}
}
when HTTP_RESPONSE {
set client [IP::client_addr]:[TCP::client_port]
set node [IP::server_addr]:[TCP::server_port]
set nodeResp [HTTP::status]
log local0.info "SUMMARY: Client: $client -> VIP name is [virtual name] $vip and URL is $url -> Node: $node with response $nodeResp"
}
}
Request from a client:
curl -v -H 'X-SLOWROLL: 1' http://150.29.100.98
* About to connect() to 150.29.100.98 port 80 (0)
* Trying 150.29.100.98... connected
* Connected to 150.29.100.98 (150.29.100.98) port 80 (0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 OpenSSL/1.0.1l zlib/1.2.3 libidn/0.6.5
> Host: 150.29.100.98
> Accept: */*
> X-SLOWROLL: 1
>
< HTTP/1.1 200 OK
< Content-Type: text/html
< Last-Modified: Fri, 19 Sep 2014 09:29:52 GMT
< Accept-Ranges: bytes
< ETag: "7bf75a44ecd3cf1:0"
< Server: Microsoft-IIS/7.5
< Date: Tue, 19 Apr 2016 05:32:06 GMT
< Content-Length: 1162
Log output:
Apr 18 15:33:36 MAMA-ATM-SGDC info tmm1[11293]: Rule /Common/SLOWROLL : HTTP REQUEST HEADER User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 OpenSSL/1.0.1l zlib/1.2.3 libidn/0.6.5
Apr 18 15:33:36 MAMA-ATM-SGDC info tmm1[11293]: Rule /Common/SLOWROLL : HTTP REQUEST HEADER Host: 150.29.100.98
Apr 18 15:33:36 MAMA-ATM-SGDC info tmm1[11293]: Rule /Common/SLOWROLL : HTTP REQUEST HEADER Accept: */*
Apr 18 15:33:36 MAMA-ATM-SGDC info tmm1[11293]: Rule /Common/SLOWROLL : HTTP REQUEST HEADER X-SLOWROLL: 1
Apr 18 15:33:36 MAMA-ATM-SGDC info tmm1[11293]: Rule /Common/SLOWROLL : SUMMARY: Client: 150.29.100.3:49555 -> VIP name is /Common/HSL_TEST_VS 150.29.100.98:80 and URL is 150.29.100.98/ -> Node: 10.29.100.20:80 with response 200
Why do we need to do the for each here?
foreach aHeader [HTTP::header names] {
log local0. "HTTP REQUEST HEADER $aHeader: [HTTP::header value $aHeader]"
}
- Mayur_SutareSep 18, 2020
MVP
,
With this, your virtual server itself won't show/become available. Kindly configure a pool and add required node under it with service port where your service/application is running. So F5 will forward request to the node on configured service. With this, if pool come up, your virtual server will also become available once you configure iRule on it. And it will work as expected.
when CLIENT_ACCEPTED { pool POOL_NAME }
Hope it helps!
- Pedro_BoavidaSep 18, 2020
Nimbostratus
Hi,
The missing code in the irule performs a name lookup to determine its IP address (dynamic).
It used to work before.
Thanks for your help anyway.
Regards
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