> On Feb 27, 2020, at 10:37 AM, David Calavera <[email protected]> wrote:
>
> Why can’t it just be a plain remap plugin ?
>
> That's a good question, maybe we just overlooked the obvious solution. If I
> understand what you're suggesting is to change the
> TSRemapRequestInfo->requestUrl with the new server url and call it a day.
> That might work, I don't think we care much about the cache key.
Right. Like what the regex_remap plugin essentially does:
if (TS_PARSE_ERROR == TSUrlParse(rri->requestBufp, rri->requestUrl,
&start, start + dest_len)) {
TSHttpTxnStatusSet(txnp, TS_HTTP_STATUS_INTERNAL_SERVER_ERROR);
TSError("[%s] can't parse substituted URL string", PLUGIN_NAME);
}
Or any other appropriate APIs to modify the rri->requestUrl.
Cheers,
— Leif
>
> On Thu, Feb 27, 2020 at 9:25 AM Leif Hedstrom <[email protected]> wrote:
>
>
> > On Feb 27, 2020, at 10:18 AM, David Calavera <[email protected]>
> > wrote:
> >
> > Hi all,
> >
> > What's the best practice to change the origin server URL in remap plugins?
> >
> > We're working on a dynamic plugin that can proxy certain requests to a
> > third party service and we're not sure what's the best solution.
> >
> > Should we add a transaction plugin that changes the server url in the
> > TS_HTTP_SEND_REQUEST_HDR_HOOK event? Another option that has crossed our
> > mind it to set the cache key to the original url with TSCacheUrlSet, and
> > then change the client URL.
>
>
> Why can’t it just be a plain remap plugin ? Is the concern here the cache
> key, and if so, how much are you modifying of the URL? The default cache key
> is the remapped URL (after remap / remap plugins), which is usually what you
> want (but obviously not always).
>
> — Leif
>
> P.s
> See e.g. regex_remap plugin, which is just a simple remap plugin.