trafficserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Payne <jp557...@gmail.com>
Subject Re: How to set the Host header of the request to the origin server in hierachical caching
Date Wed, 09 Mar 2016 03:13:14 GMT
at the parent layer, you will have to re-set the HOST header upon origin
communication.

you can use the header rewrite plugin or the lua plugin to do this.

header_rewrite:

https://trafficserver.readthedocs.org/en/6.0.x/reference/plugins/header_rewrite.en.html

ts_lua:

https://trafficserver.readthedocs.org/en/6.0.x/reference/plugins/ts_lua.en.html

function send_request()
    ts.server_request.header['Host'] = 'example.com'
end

function do_remap()
    ts.hook(TS_LUA_HOOK_SEND_REQUEST_HDR, send_request)
    return 0
end



On Tue, Mar 8, 2016 at 8:47 PM, Hiroaki Nakamura <hnakamur@gmail.com> wrote:

> Thanks for replies.
> However I still cannot solve the issue.
>
> I reviewed my settings and found out I already had set
> proxy.config.url_remap.pristine_host_hdr to 1
> in both the child and the parent cache.
>
> I set all these configs to 1 in both the child and the parent cache.
> CONFIG proxy.config.url_remap.remap_required INT 1
> CONFIG proxy.config.url_remap.pristine_host_hdr INT 1
> CONFIG proxy.config.reverse_proxy.enabled INT 1
>
> My remap and parent configs were like this:
>
> child remap.config
> map http://example.com/ http://origin.example.com/
>
> child parent.config
> dest_domain=. parent="parent1.example.com:9090;
> parent2.example.com:9090" round_robin=consistent_hash
>
> parent remap.config
> map http://origin.example.com/ http://origin.example.com/
>
> I changed parent remap.config like
> map http://example.com/ http://origin.example.com/
>
> Still I got the Header value origin.example.com in the request to the
> origin server.
>
> Also I add %<{Host}cqh> to the logs_xml.config of the child and the
> parent cache.
> And I found out the Host value is origin.example.com, not example.com in
> the
> parent cache proxy log.
> In the child cache proxy log, the Host value is example.com, which is
> correct.
>
> So I think the child cache does not preserve the host header.
> I'm using trafficserver version 6.1.1 on CentOS 7.
> And my proxy chain is like below.
>
> nginx -> ATS child -> ATS parent
>
> Regards,
> Hiroaki
>
> 2016-03-09 7:05 GMT+09:00 Leif Hedstrom <zwoop@apache.org>:
> >
> > On Mar 8, 2016, at 2:46 PM, Jeremy Payne <jp557198@gmail.com> wrote:
> >
> > The parent remap would then have to match on:
> >
> > map http://origin.example.com/ http://origin.example.com/
> >
> > Last time I checked this is how it worked. I know there was talks of
> having
> > a parent.config option which forced the child to send a relative URL
> > request. Instead of the full URL GET currently sent to the parent.
> >
> >
> >
> > That used to be an option in the remap configuration setting, but was
> > removed (because it was crippled). John Rushford is working on a
> replacement
> > for this feature, such that parent request follow normal (“origin”)
> request
> > semantics, and not the way parent proxying works today. I’m hoping that
> > it’ll be configurable per rule in parent.config  (and not a global
> setting
> > as it was before). Alternatively, maybe it could be an overridable
> > records.config setting.
> >
> > That much said, I believe Jeremy is right, in that pristine host headers
> > don’t apply to parent selection. It looks like parent selection happens
> > right after remapping, and it does not consider pristine host headers.
> John
> > and Phil, can you confirm?
> >
> > Note that the parent.config selection happens on the remapped host name
> (I’m
> > pretty sure, I’m sure someone will correct me :).
> >
> > Cheers,
> >
> > — Leif
> >
>

Mime
View raw message