Skip to content

Snippet in Caddyfile, Import via label? #761

@nebb00

Description

@nebb00

Is it possible to have reverse_proxy {{upstreams 8989}} set as a docker label merge into my global snippet handle which is set in my Caddyfile

# Snippets
(private-ips) {
        client_ip 192.168.1.0/24 192.168.2.0/24 192.168.39.3/32 192.168.100.0/24
}

(crowdsec) {
        route {
                crowdsec
        }
}

(protected-app) {
        import crowdsec

        handle /caddy-security/* {
                authenticate with myportal
        }

        @private {
                import private-ips
        }

        handle @private {
                authorize with mypolicy
                **insert reverse_proxy service:port here **
        }

        handle {
                respond "Access restricted to LAN" 403
        }
}

I tried with a label, but creates another duplicate block [email protected]_proxy

Removing invalid block: parsing caddyfile tokens for 'handle': matcher is defined more than once: @private\nsub.domain.com {\n\thandle {\n\t\t@private {\n\t\t\treverse_proxy 192.168.40.157:8989\n\t\t}\n\t}\n\timport protected-app\n}\n\n"}

could this work?

        handle @private {
                authorize with mypolicy
                {args[0]}
        }

then caddy.import: protected-app reverse_proxy {{upstreams 8989}}

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