Skip to content

Problem converting not.header with matcher #720

@aviv926

Description

@aviv926

While trying to convert my Caddyfile to caddy-docker-proxy I encountered a problem, I can't convert this section to labels:

mobile.site.mydomain.com {
 # Define non-mobile User-Agent matcher
 @not_mobile {
  not header User-Agent *Mobile*
  not header User-Agent Dart/3.*
  not header User-Agent Dalvik/2.*
 }
 # Redirect non-mobile users to desktop site
 redir @not_mobile https://site.mydomain.com{uri}
 # Proxy mobile users to the mobile backend
 reverse_proxy 127.0.0.1:2741

I tried so many options but none of them worked for example:

  caddy_1: "mobile.site.mydomain.com" # Main domain for the second configuration block

  caddy_1.matcher_0_name: "not_mobile"
  caddy_1.matcher_0_not_0.header: "User-Agent *Mobile*"
  caddy_1.matcher_0_not_1.header: "User-Agent Dart/3.*"
  caddy_1.matcher_0_not_2.header: "User-Agent Dalvik/2.*"

  caddy_1.redir: "@not_mobile https://site.mydomain.com{http.request.uri}"

  caddy_1.reverse_proxy: "{{upstreams http 2741}}"

logs error:

caddy     | {"level":"info","ts":1746624396.4269888,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR]  Removing invalid block: Caddyfile:36: unrecognized directive: matcher_0_name\nmobile.site.mydomain.com {\n\tmatcher_0_name not_mobile\n\tmatcher_0_not {\n\t\theader User-Agent *Mobile*\n\t}\n\tmatcher_0_not {\n\t\theader User-Agent Dalvik/2.*\n\t}\n\tmatcher_0_not {\n\t\theader User-Agent Dart/3.*\n\t}\n\tredir @not_mobile https://site.mydomain.com{http.request.uri}\n\treverse_proxy http://172.21.0.6:2741\n}\n\n"}

Can anyone show me the correct way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions