Skip to content

Underdocumented: path match precedence #1222

Closed

Description

@eshattow

I would like to match all except for path prefix /.well-known/acme-challenge on one http protocol cluster, and match path prefix /.well-known/acme-challenge on another http protocol cluster, when the frontend host and port will be the same. How to do this?

Use case: Stalwart mail server on the same host as a general-use Apache2 web server; Stalwart operates JMAP protocol and web administration interface on port 443 at mail.domain.tld from the same server address as a general-use Apache2 web server; certificate renewal is maintained by use of certbot webroot operating mode, which for mail.domain.tld we want directed to Apache2 web server to serve the ACME challenge data but all other requests for mail.example.tld should be passed through to the Stalwart mail server; all requests for example.tld should be directed to Apache2 web server.

Problem 1: Not clear in documentation the precedence of PREFIX versus REGEX, so also not clear if the ordering in configuration is deterministic to allow this by defining one and then modifying the scope by a later definition.

Problem 2: Does the REGEX allow for look-around? If not, can there be an option for fancy-regex to allow this?

path = '^(\/\.well-known\/acme-challenge)', path_type = "REGEX"

above appears functional.

path = '^(?!\/\.well-known\/acme-challenge)', path_type = "REGEX"

above does not appear to be working as intended, are we missing look-around functionality in sozu?

However, pairing

path = '/', path_type = "PREFIX"

for the frontend to Stalwart mail backend port on localhost and with

path = '^(\/\.well-known\/acme-challenge)', path_type = "REGEX"

for the frontend to Apache2 web server backend port on same localhost, is functional but I don't know if this is a coincidence that it works. Is there an assured precedence?

Activity

  1. FlorentinDUBOIS commented on May 2, 2026

    @FlorentinDUBOIS
    Collaborator

    Addressed in PR #1236: doc/configure.md gains a 'Path matching precedence' subsection that documents the explicit ordering — EQUALS wins first, then anchored REGEX, then PREFIX with longest-match — plus a worked example for the /.well-known/acme-challenge vs / split. The regex-look-around limitation is also documented (Rust regex does not support look-around; decompose into PREFIX rules using longest-match precedence, or declare explicit EQUALS rules).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions