trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Is there a way to customize body factory response headers?

Open nikolqy opened this issue 2 years ago • 2 comments

I am trying to customize an error document and I would like to change the content-type to text/plain, or remove the header completely. I don't mind modifying and recompiling it myself, but I feel like there must be some way to do this.

For example, with HAProxy, you can achieve similar behavior directly in the response bodies.

HTTP/1.1 403 go away
Content-Type: text/html

error msg

or like this for minimum response size

HTTP/1.1 403

error msg

Thanks!

nikolqy avatar Dec 01 '23 04:12 nikolqy

I think you can use a plugin to do that. Either

header_rewrite or lua will do - https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/header_rewrite.en.html https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/lua.en.html

You can have a handler for the "read response" hook in either case and simply override or remove the the client response header for "Content-Type".

shukitchan avatar Dec 01 '23 08:12 shukitchan

etc/trafficserver/body_factory/default is that the error messages you looking for? I think you can define this as you wish at site wide config.

mingzym avatar Dec 23 '23 10:12 mingzym