Forum Discussion
avnishvyas_1974
Nimbostratus
Apr 06, 2017iRule help with adding a customer header
Im trying to write an iRule for the following if response from a particular URL [] returns a 401 then to add a custom header with WWW-AUTHENTICATE with dummy value BASIC realm="USER VISIBLE REALM" or...
Leonardo_Souza
Cirrocumulus
Apr 06, 2017Yes, should work.
I just tested the iRule, with small change to match my lab environment.
Headers without iRule:
HTTP/1.1 200 OK
Date: Thu, 06 Apr 2017 11:16:07 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
X-Powered-By: PHP/5.4.16
Set-Cookie: Chocolate=Price%3D1pound; expires=Thu, 06-Apr-2017 11:17:07 GMT
Set-Cookie: Coconut=Price%3D2pounds; expires=Thu, 06-Apr-2017 11:18:07 GMT
Content-Length: 503
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
iRule:
when HTTP_RESPONSE {
if { ( [HTTP::status] eq "200" ) and ( [HTTP::header exists X-Powered-By] ) } {
HTTP::header replace X-Powered-By "ok"
}
}
Headers after iRule applied to virtual server:
HTTP/1.1 200 OK
Date: Thu, 06 Apr 2017 11:18:43 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
X-Powered-By: ok
Set-Cookie: Chocolate=Price%3D1pound; expires=Thu, 06-Apr-2017 11:19:43 GMT
Set-Cookie: Coconut=Price%3D2pounds; expires=Thu, 06-Apr-2017 11:20:43 GMT
Content-Length: 497
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects