You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2026/01/05 16:42:21 UTC

(trafficserver) branch 10.1.x updated (9380307f8d -> c28a5da23b)

This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


    from 9380307f8d Fix HTTP caching compliance by adding Vary headers for compressible c… (#12764)
     new e2f12416ff Decouple recursive var in CacheVC (#12771)
     new c28a5da23b regex_remap: Document host option // prefix behavior (#12730)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/admin-guide/plugins/regex_remap.en.rst | 66 +++++++++++++++++++++++++++++-
 src/iocore/cache/CacheRead.cc              |  6 +--
 src/iocore/cache/CacheVC.h                 |  1 +
 3 files changed, 69 insertions(+), 4 deletions(-)


(trafficserver) 01/02: Decouple recursive var in CacheVC (#12771)

Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit e2f12416ffce9ca52fa0dc70b511b4b9b7b65d6d
Author: Serris Santos <se...@gmail.com>
AuthorDate: Fri Jan 2 09:19:17 2026 -0800

    Decouple recursive var in CacheVC (#12771)
    
    Co-authored-by: Serris Lew <ls...@apple.com>
    (cherry picked from commit bf1ef914d8971b294ba09dac544ebfb417605490)
---
 src/iocore/cache/CacheRead.cc | 6 +++---
 src/iocore/cache/CacheVC.h    | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/iocore/cache/CacheRead.cc b/src/iocore/cache/CacheRead.cc
index 9826b0854d..7964917217 100644
--- a/src/iocore/cache/CacheRead.cc
+++ b/src/iocore/cache/CacheRead.cc
@@ -821,12 +821,12 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS
       if ((call_result = do_read_call(&key)) == EVENT_RETURN) {
         if (this->handler == reinterpret_cast<ContinuationHandler>(&CacheVC::openReadStartEarliest)) {
           is_recursive_call = true;
-          if (recursive > MAX_READ_RECURSION_DEPTH) {
+          if (read_recursive > MAX_READ_RECURSION_DEPTH) {
             char tmpstring[CRYPTO_HEX_SIZE];
             Error("Too many recursive calls with %s", key.toHexStr(tmpstring));
             goto Ldone;
           }
-          ++recursive;
+          ++read_recursive;
         }
 
         goto Lcallreturn;
@@ -901,7 +901,7 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS
 Lcallreturn:
   event_result = handleEvent(AIO_EVENT_DONE, nullptr); // hopefully a tail call
   if (is_recursive_call) {
-    --recursive;
+    --read_recursive;
   }
   return event_result;
 Lsuccess:
diff --git a/src/iocore/cache/CacheVC.h b/src/iocore/cache/CacheVC.h
index 9c362fc2d0..6d31d4610c 100644
--- a/src/iocore/cache/CacheVC.h
+++ b/src/iocore/cache/CacheVC.h
@@ -268,6 +268,7 @@ struct CacheVC : public CacheVConnection {
   ink_hrtime                start_time;
   int                       op_type; // Index into the metrics array for this operation, rather than a CacheOpType (fewer casts)
   int                       recursive;
+  int                       read_recursive;
   int                       closed;
   uint64_t                  seek_to;       // pread offset
   int64_t                   offset;        // offset into 'blocks' of data to write


(trafficserver) 02/02: regex_remap: Document host option // prefix behavior (#12730)

Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit c28a5da23b051e1ee6b2fd7128a6e36284308c4d
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Thu Dec 11 20:05:54 2025 -0600

    regex_remap: Document host option // prefix behavior (#12730)
    
    The host option prepends // to the match string, which can be
    unintuitive when regex_remap rules. This adds documentation explaining
    why the // prefix exists (to distinguish hostnames from hostname-like
    path components) and provides practical examples showing how to write
    redirect rules correctly using https:$1 instead of https://$1.
    
    Fixes: #12691
    (cherry picked from commit e5cd67e23eca35193e70c04d02a86bfa190c2977)
---
 doc/admin-guide/plugins/regex_remap.en.rst | 66 +++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)

diff --git a/doc/admin-guide/plugins/regex_remap.en.rst b/doc/admin-guide/plugins/regex_remap.en.rst
index 7ac4001c61..6156aafc4f 100644
--- a/doc/admin-guide/plugins/regex_remap.en.rst
+++ b/doc/admin-guide/plugins/regex_remap.en.rst
@@ -99,8 +99,19 @@ With this enabled, the string that you will need to match will look like ::
 
     //host/path?query=bar
 
+Note carefully that this includes the ``//`` prefix.  This makes it possible to
+distinguish between the hostname and path components in cases where hostnames
+appear in the path. Consider, for example, a CDN that routes requests based on
+the origin hostname in the path, like this::
 
-A typical regex would look like ::
+    https://cdn.example.com/origin1.example.com/some/path
+
+The ``//`` prefix allows you to write a regex that reliably identifies the
+actual hostname versus a hostname-like string in the path. See the example
+for a demonstration of how to use the ``host`` option.
+
+A typical regex, without the above mentioned method or host options, would look
+like::
 
     ^/(ogre.*)/more     http://www.ogre.com/$h/$0/$1
 
@@ -170,3 +181,56 @@ as a redirect (Location:).
 You can also combine multiple options, including overridable configs ::
 
     ^/(.*)?$            https://example.com/sitemaps/$1 @proxy.config.url_remap.pristine_host_hdr=0 @status=301
+
+Examples
+~~~~~~~~
+
+**Example: Basic path rewriting**
+
+By default, regex_remap matches against the URL path and query string, which
+always starts with ``/``. This example rewrites requests from an old URL
+structure to a new one::
+
+    # remap.config:
+    map http://www.example.com http://backend.example.com @plugin=regex_remap.so @pparam=rewrites.conf
+
+    # rewrites.conf:
+    ^/old/(.*)$    http://backend.example.com/new/$1
+
+A request to ``http://www.example.com/old/page.html`` will be rewritten to
+``http://backend.example.com/new/page.html``. The ``$1`` substitution captures
+the first parenthesized group from the regex match.
+
+**Example: HTTP to HTTPS redirect with host matching**
+
+To redirect all HTTP requests to HTTPS while preserving the host and path,
+use the ``host`` option. With ``@pparam=host``, the match string is
+``//host/path?query`` (note the ``//`` prefix), so the following rule captures
+the entire string and redirects to HTTPS. Because the captured group includes
+the ``//``, the substitution uses ``https:`` without ``//`` to avoid producing
+a malformed URL with four slashes::
+
+    # remap.config:
+    regex_map http://(.*) https://unused.invalid @plugin=regex_remap.so @pparam=redirect.conf @pparam=host @pparam=pristine
+
+    # redirect.conf:
+    ^(.*)$    https:$1    @status=307
+
+This will redirect any plaintext HTTP (``http://``) request for any host to the
+``https://`` equivalent. For instance, a request to ``http://example.com/path``
+would be redirected to ``https://example.com/path``.
+
+**Example: Method-based routing**
+
+To route requests differently based on the HTTP method, use the ``method``
+option. With ``@pparam=method``, the match string is ``METHOD/path?query``
+(note no space between method and path)::
+
+    # remap.config:
+    map http://api.example.com http://backend.example.com @plugin=regex_remap.so @pparam=api.conf @pparam=method
+
+    # api.conf:
+    ^GET/api/v1/(.*)$     http://read-replica.example.com/api/v1/$1
+    ^POST/api/v1/(.*)$    http://write-primary.example.com/api/v1/$1
+
+This routes GET requests to a read replica and POST requests to the primary.