{
"apps": {
"http": {
"servers": {
"example": {
"listen": [
":80",
":443"
],
"routes": [
{
"match": [
{
"host": [
"mydomain.co.uk"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:8080"
}
]
}
]
}
]
}
]
}
]
}
}
},
"tls": {
"automation": {
"policies": [
{
"subjects": [
"mydomain.co.uk"
],
"issuer": {
"challenges": {
"dns": {
"provider": {
"api_token": "<api token goes here>",
"name": "cloudflare"
}
}
},
"email": "<email address used for cloudflare account>",
"module": "acme"
}
}
]
}
}
}
}
Last active
March 25, 2024 22:58
-
-
Save fizzyade/8b7978c9001c9dde987c16bdfa322a01 to your computer and use it in GitHub Desktop.
An example of a Caddy 2 JSON configuration file for a reverse proxy that uses the Cloudflare DNS module
sae13
commented
Dec 2, 2021
@sae13
seems issuer: { ... }
format is gone,
replaced by issuers:[ {...} ]
and
api_token
may auth_token
// can't find a demo in offical docs
after litte try, here is a v2 demo.json
:
- run https at port :3443
- file brower
- with tls issuers by dns
{
"admin": {
"disabled": true
},
"apps": {
"http": {
"servers": {
"static": {
"automatic_https": {
"disable_redirects": true
},
"idle_timeout": 30000000000,
"listen": [
":3443"
],
"max_header_bytes": 10240,
"read_header_timeout": 10000000000,
"routes": [
{
"handle": [
{
"browse": {},
"handler": "file_server",
"root": "/home/chen/down/"
}
],
"match": [
{
"host": [
"your.domain.com"
]
}
]
}
]
}
}
},
"tls": {
"automation": {
"policies": [
{
"subjects": [
"your.domain.com"
],
"issuers": [
{
"module": "acme",
"challenges": {
"dns": {
"provider": {
"name": "dnspod",
"auth_token": "id,token"
}
}
}
}
]
}
]
}
}
}
}
json format is not easy for manual.
so here is a caddyfile:
- https @ :3443
- file browser @ /public
# global conf
{
auto_https disable_redirects
#acme_dns dnspod your_id,your_token
}
# server
your.domain.com:3443 {
#root * /srv/http
tls {
dns dnspod your_id,your_token
}
handle /public/* {
root ./down
uri strip_prefix /public
file_server browse
}
file_server
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment