trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Feature request for remapping rules via SRV records

Open tuaris opened this issue 4 months ago • 4 comments

I wrote a very crude C program (with some help getting started using AI) for fetching SRV records to generate a remap.confg file. I called it trafficmap. It takes in a text file with a list of domains. One would run the program and then reload traffic server.

SRV records look like this:

_http._tcp		IN	SRV	5 0 8002 web03.domain.tld.
_http._tcp.www	IN	SRV	5 0 8002 web03.domain.tld.

The resulting remap.config looks like this:

map http://mywebsite.tld http://web03.domain.tld:8002
map http://www.mywebsite.tld  http://web03.domain.tld:8002

I'd like to see a feature in Traffic Server where this would happen in real time with caching (while respecting TTL). Without having the need to pre-generate any configuration. Changes and new additions would propagate automatically through DNS. A plugin would be fine, but I'd prefer to not have that via Lua scripting/plugin.

tuaris avatar Aug 11 '25 03:08 tuaris

If I'm understanding correctly you can set proxy.config.srv_enabled to 1 to use SRV for the origin -- so if you had map http://mywebsite.tld https://origindomain.tld with the setting (either in records.yaml or via the conf_remap plugin) and dig _https._tcp.origindomain.tld -t SRV _https._tcp.origindomain.tld IN SRV 5 0 8002 web03.domain.tld. _https._tcp.origindomain.tld IN SRV 5 0 8002 web04.domain.tld. _https._tcp.origindomain.tld IN SRV 5 0 8002 web05.domain.tld.

you'd round robin across the 3 web0[#]

mlibbey avatar Aug 13 '25 00:08 mlibbey

It does indeed work. Is this a relatively new feature? I'm almost certain I spent time lots of researching this more than a year ago.

This part of the docs confuse me:

Also note that the port returned in the SRV record MUST match the port being used for the origin (e.g. if the origin scheme is http and a default port, there should be a SRV record with port 80).

I assume that's referring to the protocol (_http._tcp) and not the SRV location port number.

If the SRV records exists in the same zone I would end up building a remap.config file that looks like this:

map http://domain.tld http://domain.tld
map http://www.domain.tld http://www.domain.tld

It's satisfying, but the syntax can probably be improved.

Maybe do away with having to build mappings and provide Traffic Server a list of domains.

tuaris avatar Aug 13 '25 02:08 tuaris

I'd love to improve the docs! What about adding more to the example. Like,

For instance, if the origin is set to https://my.example.com, Traffic Server would lookup the SRV record for _https._tcp.my.example.com, and use the records that reference 443 as the port (like _https._tcp.my.example.com. 10 IN SRV	10 1 443 server1.example.com). Note that the port returned in the SRV record MUST match the port being used for the origin (e.g. if the origin scheme is http and a default port, there should be a SRV record containing port 80).

mlibbey avatar Aug 13 '25 16:08 mlibbey

Seems like we should probably write a paragraph some other place in the admin guide about this. Do you have suggestions where? (eg, do you remember part of the research path to look for the feature?)

mlibbey avatar Aug 13 '25 16:08 mlibbey