1. The problem I’m having:
1.1 cannot set on-dmand tls with json config
1.2 optionally allow for local https
2. Error messages and/or full log output:
docker logs ca
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
docker run
a. System environment:
docker
b. Command:
"Args": [
"caddy",
"run",
"--config",
"/etc/caddy/caddy.json"
],
c. Service/unit/compose file:
d. My complete Caddy config:
{
"admin": {
"disabled": false,
"listen": ":2019",
"enforce_origin": false
},
"logging": {
"logs": {
"": {
"level": "DEBUG"
}
}
},
"storage": {
"module": "file_system",
"root": "/data/caddy"
},
"apps": {
"http": {
"http_port": 80,
"https_port": 443,
"servers": {
"example": {
"listen": [
":80",
":31080",
":443",
":31443"
],
"routes": [
{
"handle": [
{
"handler": "static_response",
"body": "Hello, world 24!"
}
]
}
],
"automatic_https": {
"disable": false
}
}
}
},
"tls": {
"automation": {
"on_demand": {
"permission": {
"module": "http",
"endpoint": "http://192.168.29.201:4000/api/check-domain"
}
},
"policies": [
{
"issuers": [
{
"module": "acme",
"ca": "https://acme-v02.api.letsencrypt.org/directory"
}
]
}
]
}
}
}
}
5. Links to relevant resources:
i have http://192.168.29.201:4000/api/check-domain
const express = require('express');
const app = express();
app.get('/api/check-domain', (req, res) => {
const domain = req.query.domain;
console.log('WORKING ', domain);
// Implement your logic to check if the domain should be allowed
res.status(200).send('OK');
if (isValidDomain(domain)) {
} else {
res.status(403).send('Forbidden');
}
});
function isValidDomain(domain) {
// Your domain validation logic here
// For example, you can check against a database of allowed domains
return true; // Placeholder for actual logic
}
app.listen(4000, () => {
console.log('Server is running on port 4000');
});
// http://192.168.29.201:3000/api/check-domain
which simply returns 200 OK
The caddy json config is:
- not redirecting http to https
- not generating ssl certificates for wildcard domain