You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Hiroaki Nakamura <hn...@gmail.com> on 2016/09/28 07:36:31 UTC

How to set the origin server status as a custom header?

Hi,

How to set the origin server status as a custom header?

I tried the header rewrite plugin with ATS 6.2.0 with the following configs.

plugin.config
```
header_rewrite.so header_rewrite.config
```


header_rewrite.config

```
cond %{SEND_RESPONSE_HDR_HOOK}
set-header X-Origin-Status %{STATUS}
```

However I got the following response header.

X-Origin-Status: 0

I expected the value is 200, not 0.

Thanks,
Hiroaki Nakamura

Re: How to set the origin server status as a custom header?

Posted by Hiroaki Nakamura <hn...@gmail.com>.
It turns out that I can do this with the TS Lua plugin instead of the
header rewrite plugin.

plugin.config
```
tslua.so /etc/trafficserver-second/set_origin_status.lua
```

/etc/trafficserver-second/set_origin_status.lua
```
function do_global_send_response()
    local code = ts.server_response.get_status()
    ts.client_response.header['X-Origin-Status'] = code
    return 0
end
```

Thanks,
Hiroaki Nakamura


2016-09-28 16:36 GMT+09:00 Hiroaki Nakamura <hn...@gmail.com>:
> Hi,
>
> How to set the origin server status as a custom header?
>
> I tried the header rewrite plugin with ATS 6.2.0 with the following configs.
>
> plugin.config
> ```
> header_rewrite.so header_rewrite.config
> ```
>
>
> header_rewrite.config
>
> ```
> cond %{SEND_RESPONSE_HDR_HOOK}
> set-header X-Origin-Status %{STATUS}
> ```
>
> However I got the following response header.
>
> X-Origin-Status: 0
>
> I expected the value is 200, not 0.
>
> Thanks,
> Hiroaki Nakamura