Forum Discussion
drumik_61546
Nimbostratus
Oct 14, 2009Removing Headers from IIS
Weird issue. The script work some times, some times it doesn't.
Sometimes it's removing all the headers, sometimes it does what it suppose to do
Any ideas? I
m runing 9.4.6
when RULE_INIT {
Create a list of the response headers to preserve. This needs to be tailored to the application!
set ::headers_to_preserve [list \
Accept-Ranges\
Cache-Control\
Connection\
Content-Disposition\
Content-Encoding\
Content-Length\
Content-Type\
Date\
ETag\
Last-Modified\
Pragma\
Set-Cookie\
Location\
X-PvInfo\
Vary\
Transfer-Encoding\
Expires\
]
Log debug messages to /var/log/iisheader? 1=yes, 0=no.
set ::clocking_debug 1
}
when HTTP_RESPONSE {
Remove all headers but those in the preserve list
foreach aHeader [HTTP::header names] {
if {not ([matchclass $::headers_to_preserve equals $aHeader])}{
while {[HTTP::header exists $aHeader]}{
if {$::clocking_debug}{log local0. "Removing: $aHeader: [HTTP::header value $aHeader]"}
HTTP::header remove $aHeader
}
}
}
}
- hoolio
Cirrostratus
That looks like it should work fine. Is there any pattern to the failures? Are no headers removed from some responses? Or is it just some headers that aren't removed from some responses? What do the logs show when a failure occurs? - drumik_61546
Nimbostratus
Seems to be that whenever we have more load (not a lot about 5 concurrent connections) irule stops working as it suppose to (it starts removing all headers except Date & ETag) - Another option is to use the HTTP::sanitize command which allows you to specify which headers you DO want to pass through. The command will remove all other response headers.
- drumik_61546
Nimbostratus
Posted By Joe Pruitt on 10/14/2009 10:31 AM
- hoolio
Cirrostratus
I think the HTTP::header sanitize function would be a lot more useful if it didn't leave a default set of headers and an admin could fully configure the white list of headers to keep. It seems to be designed for response use and by default would break just about any app if used in requests. - You could always use it in conjunction with a HTTP::header remove.
HTTP::sanitize "header1to" header2" if { [HTTP::header exists "Proxy-Connection" } { HTTP::header remove "Proxy-Connection" }
- drumik_61546
Nimbostratus
Posted By Joe Pruitt on 10/14/2009 10:42 AM
HTTP::sanitize "header1to" header2" if { [HTTP::header exists "Proxy-Connection" } { HTTP::header remove "Proxy-Connection" }
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