Hi,

I enabled diags in traffic.out as you told except it does not work the diags 
has to be specified like this :
CONFIG proxy.config.diags.debug.tags STRING header_rewrite

I removed the call to "header_rewrite" in plugin.config and tried one 
header_rewrite config file by tld as explained earlier. None of them is parsed 
then they are not used at all.

All conditions and rewrite rules in one file caused ATS to crash and an empty 
response as exposed earlier too:

==> traffic.out <==
[May 26 11:34:18.071] Server {0x804007800} DIAG: (header_rewrite_dbg) Calling 
CTOR for Resources (InkAPI)
[May 26 11:34:18.071] Server {0x804007800} DIAG: (header_rewrite) Building 
resource structure for hook (4)
[May 26 11:34:18.071] Server {0x804007800} DIAG: (header_rewrite)       Adding 
TXN client request header buffers
[May 26 11:34:18.071] Server {0x804007800} DIAG: (header_rewrite)       Adding 
TXN server response header buffers
[May 26 11:34:18.071] Server {0x804007800} DIAG: (header_rewrite) Getting 
Header: Host, field_loc: 0x805810fe0
FATAL: InkAPI.cc:3100: failed assert `sdk_sanity_check_field_handle(field, hdr) 
== TS_SUCCESS`
/usr/local/bin/traffic_server - STACK TRACE: 
0x800b0138b <ink_fatal+0x7b> at /usr/local/lib/libtsutil.so.5
0x800b00712 <_ink_assert+0x22> at /usr/local/lib/libtsutil.so.5
0x4a7349 <_TSReleaseAssert+0x9> at /usr/local/bin/traffic_server
0x4ad185 <TSMimeHdrFieldValueStringGet+0xb5> at /usr/local/bin/traffic_server
0x8094ccbb3 
<_ZN15ConditionHeader12append_valueERNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERK9Resources+0xb3>
 at /usr/local/libexec/trafficserver/header_rewrite.so
0x8094ccc3e <_ZN15ConditionHeader4evalERK9Resources+0x2e> at 
/usr/local/libexec/trafficserver/header_rewrite.so
0x8094d2508 <TSPluginInit+0x378> at 
/usr/local/libexec/trafficserver/header_rewrite.so
0x50a310 <_ZN6HttpSM17state_api_calloutEiPv+0x540> at 
/usr/local/bin/traffic_server
0x50e636 <_ZN6HttpSM33state_read_server_response_headerEiPv+0x3c6> at 
/usr/local/bin/traffic_server
0x5066d6 <_ZN6HttpSM12main_handlerEiPv+0x96> at /usr/local/bin/traffic_server
0x61bc22 <_ZN18UnixNetVConnection11net_read_ioEP10NetHandlerP7EThread+0x5d2> at 
/usr/local/bin/traffic_server
0x615c44 <_ZN10NetHandler12mainNetEventEiP5Event+0x634> at 
/usr/local/bin/traffic_server
0x63382d <_ZN7EThread13process_eventEP5Eventi+0xcd> at 
/usr/local/bin/traffic_server
0x633fa7 <_ZN7EThread7executeEv+0x5b7> at /usr/local/bin/traffic_server
0x632963 <_ZN6Thread5startEPKcmPFPvS2_ES2_+0x103> at 
/usr/local/bin/traffic_server
0x8021af4a4 <pthread_create+0x764> at /lib/libthr.so.3

I just would like to understand how I can rewrite header depending on the host 
the client need to join.

Regards,
Denis
PS : If my query is not well placed, maybe I would have to make on 
u...@trafficserver.apache.org

----- Mail original -----
De: "Nick Berry" <nibe...@linkedin.com>
À: dev@trafficserver.apache.org
Envoyé: Jeudi 22 Mai 2014 19:52:23
Objet: Re: [ATS 4.1.2] rewrite_header confusion


On May 22, 2014, at 3:06 AM, geo...@free.fr wrote:

> Hi,
> I am trying to set up several rewrite header rules files to use one by a 
> regex_map rule based on tld.
> I can't get them parsed during ATS startup :
> ==> error.log <==
> 20140522.11h18m41s header_rewrite: failed to parse configuration file
> 
> I'm running FreeBSD 9.2 release, ATS 4.1.2 built from ports, all files are in 
> "/usr/local/etc/trafficserver" r+w by ATS processes. It work when using a 
> global
> 
> ==>remap.config
> regex_map http://www.foo.fr http://10.10.16.3/ plugin=header_rewrite.so 
> @pparam=/usr/local/etc/trafficserver/header_rewrite_fr.config
> regex_map http://www.foo.cz http://10.10.16.3/ plugin=header_rewrite.so 
> @pparam=/usr/local/etc/trafficserver/header_rewrite_cz.config

Your example remap.config should be @plugin=header_rewrite.so instead of 
plugin=header_rewrite.so.

> ==> plugin.config
> header_rewrite.so
> 
> ==>header_rewrite_cz.config
> cond %{READ_RESPONSE_HDR_HOOK} AND
> cond %{CLIENT-HEADER:Host} =www.foo.cz
> rm-header Cache-Control
> add-header Cache-Control max-age=4000 [L]
> 
> ==>header_rewrite_fr.config
> cond %{READ_RESPONSE_HDR_HOOK} AND
> cond %{CLIENT-HEADER:Host} =www.foo.fr
> rm-header Cache-Control
> add-header Cache-Control max-age=10000 [L]
> 
> No header changes are made at all :c

If you’re specifying header_rewrite.so in plugins.config, it needs a config 
file defined like you have below.

> Worst when I used a global configuration file to rewrite_header plugin
> ==> plugin.config
> header_rewrite.so /usr/local/etc/trafficserver/header_rewrite.config
> 
> ==>header_rewrite.config
> cond %{READ_RESPONSE_HDR_HOOK} AND
> cond %{CLIENT-HEADER:Host} =www.foo.cz
> rm-header Cache-Control
> add-header Cache-Control max-age=4000 [L]
> cond %{READ_RESPONSE_HDR_HOOK} AND
> cond %{CLIENT-HEADER:Host} =www.foo.fr
> rm-header Cache-Control
> add-header Cache-Control max-age=10000 [L]
> 
> # curl -I -H "Host: www.foo.fr" "http://10.10.16.28:8080/o5k";
> curl: (52) Empty reply from server

Can you enable diags and report the debug info in traffic.out?  You can do this 
by setting these two options in records.config and restarting trafficserver:
CONFIG proxy.config.diags.debug.enabled INT 1
CONFIG proxy.config.diags.debug.tags STRING header_rewrite.*

Reply via email to