How can i respond the variable as response something like this
:80 {
respond {http.request.host}
}
OR is there any way to log the caddy variable within the log output ?
sometime like this
log.print {http.request.host}
How can i respond the variable as response something like this
:80 {
respond {http.request.host}
}
OR is there any way to log the caddy variable within the log output ?
sometime like this
log.print {http.request.host}
Please fill out the help topic template. It’s relevant to know which version you’re running, etc.
You can enable access logs, which will contain the request’s hostname. Just use the log
directive to turn them on.
caddy version
):v2.4.5
caddy run --config /etc/caddy/Caddyfile
Ubuntu 20
caddy run --config /etc/caddy/Caddyfile
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.
:80 {
redir https://{host}{uri}
}
Cannot log the variables to the console
Cannot log the variables to the console
log {host}
As you can see the log does not contains all the variables e.g. {http.request.host.labels.*}
so how do I log all the variables in terminal ? may be something like this log {http.request.host.labels}
2021/12/27 15:38:59.200 INFO http.log.access handled request {"request": {"remote_addr": "147.243.169.137:49728", "proto": "HTTP/1.1", "method": "HEAD", "host": "20.93.8.238", "uri": "/ping", "headers": {"User-Agent": ["Edge Health Probe"], "X-Azure-Fdid": ["cca02156-ca13-4d02-a19a-664232037408"], "X-Fd-Healthprobe": ["1"]}}, "common_log": "147.243.169.137 - - [27/Dec/2021:15:38:59 +0000] \"HEAD /ping HTTP/1.1\" 200 4", "user_id": "", "duration": 0.000048604, "size": 4, "status"
Those aren’t “variables”, they’re “placeholders” that get replaced at runtime (on-demand closures, basically). So there’s no way to output “all variables”.
But the value for {http.request.host}
will be this one:
Labels are the index of the segments of the hostname separated by .
starting from the right, so labels.0
will be 238
, labels.1
will be 8
, etc.
This topic was automatically closed after 30 days. New replies are no longer allowed.