Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 47098fb

Browse files
authored
t3c: use mustache templating for remap.config lines (#7155)
1 parent 098354c commit 47098fb

File tree

15 files changed

+2003
-128
lines changed

15 files changed

+2003
-128
lines changed

LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,3 +712,8 @@ This product bundles jcmturner/rpc.v1, which is available under an Apache-2.0 li
712712
@vendor/gopkg.in/jcmturner/rpc.v1/*
713713
./vendor/gopkg.in/jcmturner/rpc.v1/LICENSE
714714
Refer to the above license for the full text.
715+
716+
This product bundles cbroglie/mustache which is available under an MIT license.
717+
@vendor/github.com/cbroglie/mustache/*
718+
./vendor/github.com/cbroglie/mustache/LICENSE
719+
Refer to the above license for the full text.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# DO NOT EDIT - Generated for atlanta-edge-03 by () on Fri Nov 13 18:49:10 UTC 2020
2-
map http://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
3-
map https://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
4-
map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
5-
map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
2+
map http://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
3+
map https://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
4+
map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
5+
map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'

docs/source/overview/profiles_and_parameters.rst

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,60 @@ In order to support difficult configurations at MID/LAST, a
616616
and Value the raw remap lines. The Value in this parameter will be pre
617617
or post pended to the end of ``remap.config``.
618618

619-
.. seealso:: For an explanation of the syntax of this configuration file, refer to `the Apache Traffic Server remap.config documentation <https://docs.trafficserver.apache.org/en/7.1.x/admin-guide/files/remap.config.en.html>`_.
619+
To provide the most flexibility for managing :term:`Delivery Service` generated ``remap.config`` lines there are options for redefining the internal mustache template used to generate these ``remap.config`` lines.
620+
621+
- ``template.first``
622+
- ``template.inner``
623+
- ``template.last``
624+
625+
626+
.. table:: ``remap.config`` Template Tags
627+
628+
+------------------+-----------------------------------+-------------------------------+
629+
| :ref:`tag-name` | Value_ | Associated plugin/directive |
630+
+==================+===================================+===============================+
631+
| Source | Target, or request "from" URL | |
632+
+------------------+-----------------------------------+-------------------------------+
633+
| Destination | Replacement, or origin (“to”) URL | |
634+
+------------------+-----------------------------------+-------------------------------+
635+
| Strategy | NextHop selection strategy | parent_select.so |
636+
+------------------+-----------------------------------+-------------------------------+
637+
| Dscp | IP packet marking | header_rewrite.so |
638+
+------------------+-----------------------------------+-------------------------------+
639+
| HeaderRewrite | Header rewrite rules | header_rewrite.so |
640+
+------------------+-----------------------------------+-------------------------------+
641+
| DropQstring | Query string handling at edge | regex_remap.so |
642+
+------------------+-----------------------------------+-------------------------------+
643+
| Signing | URL Signing method | url_sig.so, uri_signing.so |
644+
+------------------+-----------------------------------+-------------------------------+
645+
| RegexRemap | Regex remap expressions | regex_remap.so |
646+
+------------------+-----------------------------------+-------------------------------+
647+
| Cachekey | Cachekey plugin parameters | cachekey.so |
648+
+------------------+-----------------------------------+-------------------------------+
649+
| RangeRequests | Range request handling | background_fetch.so, slice.so |
650+
+------------------+-----------------------------------+-------------------------------+
651+
| Pacing | Fair-Queuing Pacing Rate | fq_pacing.so |
652+
+------------------+-----------------------------------+-------------------------------+
653+
| RawText | Raw remap text for edge | |
654+
+------------------+-----------------------------------+-------------------------------+
655+
656+
Default internal template values:
657+
658+
.. code-block:: text
659+
:caption: Default for template.first
660+
661+
map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{Dscp}}} {{{HeaderRewrite}}} {{{DropQstring}}} {{{Signing}}} {{{RegexRemap}}} {{{Cachekey}}} {{{RangeRequests}}} {{{Pacing}}} {{{RawText}}}
662+
663+
.. code-block:: text
664+
:caption: Default for template.inner, template.last
665+
666+
map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{HeaderRewrite}}} {{{Cachekey}}} {{{RangeRequests}}} {{{RawText}}}
667+
668+
Users may use the above templates do things like manipulate the inputs to the cachekey via other plugins or modify the rule type from ``map`` to ``map_with_recv_port``.
669+
670+
.. seealso:: For an explanation of the mustache syntax of the template, refer to `the mustache spec documentation <https://github.com/mustache/spec>`_.
671+
672+
.. seealso:: For an explanation of the syntax of this ``remap.config`` file, refer to `the Apache Traffic Server remap.config documentation <https://docs.trafficserver.apache.org/en/7.1.x/admin-guide/files/remap.config.en.html>`_.
620673

621674
:file:`set_dscp_{anything}.config`
622675
''''''''''''''''''''''''''''''''''

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
2525
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
2626
github.com/basho/riak-go-client v1.7.1-0.20170327205844-5587c16e0b8b
27+
github.com/cbroglie/mustache v1.4.0
2728
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
2829
github.com/dchest/siphash v1.2.2
2930
github.com/fsnotify/fsnotify v1.5.1

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7
227227
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
228228
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
229229
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
230+
github.com/cbroglie/mustache v1.4.0 h1:Azg0dVhxTml5me+7PsZ7WPrQq1Gkf3WApcHMjMprYoU=
231+
github.com/cbroglie/mustache v1.4.0/go.mod h1:SS1FTIghy0sjse4DUVGV1k/40B1qE1XkD9DtDsHo9iM=
230232
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
231233
github.com/cactus/go-statsd-client/statsd v0.0.0-20191106001114-12b4e2b38748/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
232234
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
@@ -421,7 +423,6 @@ github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUK
421423
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
422424
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=
423425
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
424-
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
425426
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
426427
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
427428
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=

0 commit comments

Comments
 (0)