Forum Discussion
iRule to add the Server header in the HTTP Response (PLEASE HELP)
I created the iRule and need to add the Server header in the HTTP Response.
I added the iRule from the article https://support.f5.com/kb/en-us/solutions/public/10000/000/sol10089.html, but it added Xerver: ABC, not Server: ABC. I changed to Server instead but failed working. Any ideas? Please help. Thanks so much!!
In the Definition field, paste the following iRule:
when HTTP_RESPONSE { if { [HTTP::header exists "Server"] } { HTTP::header insert Xerver [HTTP::header value "Server"] } }
10 Replies
- Brad_Parker
Cirrus
If you are just trying to add/replace the server header this simple iRule should do the trick to set the server header to "ABC.
when HTTP_RESPONSE { HTTP::header replace Server "ABC" } - zeropixel_23561
Nimbostratus
I did the following to add the header, but still cannot see in the response. I have confirmed the virtual server has added the irule. By the way, I am using version 12, not 11. It shouldn't matter, I hope. Any ideas? Please help!!
when HTTP_RESPONSE { HTTP::header insert Server "ABC" }
- Brad_Parker
Cirrus
How are you verifying if the header exists?
- zeropixel_23561
Nimbostratus
https://support.f5.com/kb/en-us/solutions/public/14000/300/sol14342.html
Is "Xerver" have some meaning? I am confused why not called "Server", I used the following but it added Xerver: ABC in the response.
when HTTP_RESPONSE { if { [HTTP::header exists "Server"] } { HTTP::header insert Xerver [HTTP::header value "Server"] } } when HTTP_RESPONSE_RELEASE { if { [HTTP::header exists "Xerver"] } { HTTP::header insert Server [HTTP::header value "Xerver"] HTTP::header remove Xerver } }
- zeropixel_23561
Nimbostratus
Xerver cannot be changed to Server, it is probably the F5 keyword? I do not know the meaning though.
when HTTP_RESPONSE { if { [HTTP::header exists "Server"] } { HTTP::header insert Xerver [HTTP::header value "Server"] } } when HTTP_RESPONSE_RELEASE { if { [HTTP::header exists "Xerver"] } { HTTP::header insert Server [HTTP::header value "Xerver"] HTTP::header remove Xerver } }
- zeropixel_23561
Nimbostratus
It keep generating Xerver for me, that is frustrating.
If I change every Xerver to Server, it is just not working and cannot append the Server header in response. Any ideas please?? Thanks!!
when HTTP_RESPONSE { if { [HTTP::header exists "Server"] } { HTTP::header insert Server [HTTP::header value "Server"] } } when HTTP_RESPONSE_RELEASE { if { [HTTP::header exists "Server"] } { HTTP::header insert Server [HTTP::header value "Server"] HTTP::header remove Server } }
- zeropixel_23561
Nimbostratus
I am using Burp proxy to check the response
- Brad_Parker
Cirrus
Do you want Server to be present in the response or Xerver to the client?
- zeropixel_23561
Nimbostratus
I need Server in response header back to the browser, because client side code has validation and it is failing. It is just not working when I changed to Xerver to Server.
when HTTP_RESPONSE { if { [HTTP::header exists "Server"] } { HTTP::header insert Server [HTTP::header value "Server"] } } when HTTP_RESPONSE_RELEASE { if { [HTTP::header exists "Server"] } { HTTP::header insert Server [HTTP::header value "Server"] HTTP::header remove Server } }
Hi Zeropixel,
keep in mind that the sol10089 is referencing to a very specific scenario and also some rather old LTM versions.
If you want to preserve the server header on ASM enabled virtual servers on newer LTM versions, this code would make it...
when HTTP_RESPONSE { set server_header [HTTP::header value "Server"] } when HTTP_RESPONSE_RELEASE { if { $server_header ne "" } then { HTTP::header insert Server $server_header } }Note: It saves the original Server: header value into a variable during HTTP_RESPONSE. And then copies variable back to the Server: header during HTTP_RESPONSE_RELEASE. The reason for that is that ASM performs some header clean ups including the removal of Server: beader in between the two events.
To set a fixed server header value on ASM enabled virtual servers, use this code...
when HTTP_RESPONSE_RELEASE { HTTP::header insert Server "My-Server-Name" }But if you don't use ASM enabled virtual servers, then this command could be used to add or overwrite the server header values...
when HTTP_RESPONSE { HTTP::header replace Server "My-Server-Name" }Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
