trafficserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Moseley <>
Subject Fallback dns lookup from Lua
Date Thu, 07 Jan 2021 01:28:54 GMT
I've been using TS+Lua for a number of years now. I've got Lua doing the
remap function, so that I can use ts.client_request.set_url_host() to map
the original HTTP hostname to a central DNS domain that I manage. Servers
are all Ubuntu Bionic running the stock Bionic 7.1.2+ds-3.


Given "Host:", I do a ts.client_request.set_url_host with "" (where is the
centrally-managed domain). It gives me the ability to set the Origin DNS
without mucking with the original domains. Works great.

I'd like to set a fallback in case the DNS lookup for '' fails. It's not ideal, but it's for an
temporary internal migration and I want to make sure I don't break any
domains' traffic if there's no DNS record for "". Essentially I'd like to be able to set a
catchall in case of a DNS failure.

What I'm looking for is some way to set that fallback (either via setting
an explicit Origin IP or a hostname that'd be re-resolved), if the original
DNS lookup fails.


client -> TS -> remap to
DNS lookup succeeds? -> continue normally
DNS lookup fails? -> set_url_host() with fallback IP/hostname

I've got a hook attached to TS_LUA_HOOK_OS_DNS but it only seems to fire if
the DNS lookup succeeds. TS_LUA_HOOK_POST_REMAP seems to also fire
(or at least ts.server_request.server_addr.get_addr() returns '::'
so that's no help.

Is there any way I can call ts.client_request.set_url_host() *again* with a
fallback IP/host?

Or alternatively, set something like ts.ctx[ 'failed-dns' ] and restart the
request in TS?


View raw message