Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the upstreams template in a snippet with arguments #634

Open
grenadilla opened this issue Jun 23, 2024 · 0 comments
Open

Using the upstreams template in a snippet with arguments #634

grenadilla opened this issue Jun 23, 2024 · 0 comments

Comments

@grenadilla
Copy link

grenadilla commented Jun 23, 2024

I'm trying to write a snippet which takes in an argument and passes it as the port to the upstreams template. I've tried a few variations:

caddy: (proxy_tls)
caddy.tls: "certificate.pem private.key.pem"
caddy.reverse_proxy: "{{upstreams {args[0]}}}"

caddy.reverse_proxy.transport: http
caddy.reverse_proxy.transport.tls:
caddy.reverse_proxy.transport.tls_insecure_skip_verify:

this errors encountering an unexpected '{' character and the snippet was not able to be parsed.

Next I tried

caddy: (proxy_tls)
caddy.tls: "certificate.pem private.key.pem"
caddy.reverse_proxy: "{{upstreams `{args[0]}`}}"

caddy.reverse_proxy.transport: http
caddy.reverse_proxy.transport.tls:
caddy.reverse_proxy.transport.tls_insecure_skip_verify:

which results in a snippet which is able to be parsed. However, it seems to interpret the argument as the schema instead of the port, so it will proxy urls from 80://127.0.0.1 instead of 127.0.0.1:80.

I'm wondering if there's a way to use both the upstreams template and snippet arguments at the same time?

The result I want is

reverse_proxy ip:port {
  transport http {
    tls <insert certificate here>
    tls_insecure_verify
  }
}

as I'm proxying to an https endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant