Hi, I need one small help with Caddy configuration.
- explain what you are trying to do,
I’m trying to use the params from the request URL and put it in the Caddyfile - show what you have already tried,
proxy /rest {$COM_SRV_2}{path}?{query} {
websocket
transparent
header_downstream Access-Control-Allow-Origin "*"
}
The {$COM_SRV_2}
is a valid env var on the server.
- include error messages and log output,
Activating privacy features... done.
2019/04/26 15:29:54 parse http://{path}?{query}: invalid character "{" in host name
- and link to any relevant resources.
https://caddyserver.com/docs/placeholders
I have a Docker image that is running in the background that can be accessed (if running locally on localhost:5000/rest/cities?select=name) and it returns a JSON on the client side. In case you’re wondering, I’m using subZero. This Docker image is also up and running on my server.
NOTE: I’m using the Let’s Encrypt staging server while developing.
I have a registered domain at kosnica.ktz.rs, and I’m trying to proxy the client for when the client navigates to kosnica.ktz.rs/rest he/she receives the JSON data from the server. If you navigate to kosnica.ktz.rs/rest you should see an error 404 message, that is good, it means that the Docker image for the API is running.
The thing I’m trying to accomplish is this.
- When the client navigates to https://kosnica.ktz.rs/rest/cities?select=name, he/she should receive the response from the server in JSON type.
So my question is, how do I write the Caddyfile properly, so that the URL params are passed into Caddyfile? I need the /rest/cities param and the ?select=name query, (which are location.pathname
and location.search
in Google Chrome) and pass the strings in Caddyfile.