1. The problem I’m having:
I’m using a custom build with the http.handlers.exec module
My goal is to return the output from a command as HTTP Response
I don’t know how to do this or iif it’s possible at all with caddy
This is my current Config
:2015
route /update {
exec powershell -command (get-date).toString() {
log file caddy.log
}
}
The Command output is logged to the logfile but the http response is {"status": "success"}
How to output the that is currently logged as http response?
2. Error messages and/or full log output:
caddy run --config Caddyfile
2024/02/05 11:33:57.291 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
2024/02/05 11:33:57.292 WARN Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies {"adapter": "caddyfile", "file": "Caddyfile", "line": 4}
2024/02/05 11:33:57.295 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//127.0.0.1:2019", "//localhost:2019", "//[::1]:2019"]}
2024/02/05 11:33:57.295 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc0003f9a00"}
2024/02/05 11:33:57.295 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/02/05 11:33:57.296 INFO autosaved config (load with --resume flag) {"file": "C:\\Users\\....\\AppData\\Roaming\\Caddy\\autosave.json"}
2024/02/05 11:33:57.296 INFO serving initial configuration
2024/02/05 11:33:57.298 WARN tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:C:\\Users\\kragem\\AppData\\Roaming\\Caddy", "instance": "167e29d2-cc58-47ad-897b-1e8f482260d2", "try_again": "2024/02/06 11:33:57.298", "try_again_in": 86400}
2024/02/05 11:33:57.298 INFO tls finished cleaning storage units
2024/02/05 11:34:00.096 INFO http.handlers.exec.exit {"command": ["powershell", "-command", "(get-date).toString()"], "duration": 0.1574295}
3. Caddy version:
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
4. How I installed and ran Caddy:
b. Command:
caddy run --config Caddyfile