I’m usually familiar with caddyfiles but this one looks complicated. Any help appreciated.
You can use the nginx-adapter, but it’s best-effort and will only convert it to JSON. So you’ll have to review it and fix parts of it by hand.
I took a shot at it with the adapter and this is the output:
{
"apps": {
"http": {
"servers": {
"server_0": {
"listen": [
":80",
"[::]:80"
],
"routes": [
{
"match": [
{
"host": null
}
],
"handle": [
{
"handler": "file_server",
"index_names": [
"index.html",
"index.htm",
"index.nginx-debian.html"
],
"root": "/var/www/html"
}
]
},
{
"match": [
{
"host": [
"index.torrust-demo.com"
]
},
{
"path": [
"/api/v1/proxy*"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"uri": "$request_uri"
}
],
"match": [
{
"path_regexp": {
"pattern": "^"
}
}
]
}
]
},
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"uri": "$1"
}
],
"match": [
{
"path_regexp": {
"pattern": "^/api(/.*)"
}
}
]
}
]
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.host}"
]
}
}
},
"upstreams": [
{
"dial": "tcp/index:3001"
}
]
}
],
"match": [
{
"path": [
"/api/v1/proxy*"
]
}
]
}
]
}
]
},
{
"match": [
{
"host": [
"index.torrust-demo.com"
]
},
{
"path": [
"/api/*"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"uri": "/$1"
}
],
"match": [
{
"path_regexp": {
"pattern": "^/api/(.*)$"
}
}
]
}
]
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.host}"
]
}
}
},
"upstreams": [
{
"dial": "tcp/index:3001"
}
]
}
],
"match": [
{
"path": [
"/api/*"
]
}
]
}
]
}
]
},
{
"match": [
{
"host": [
"index.torrust-demo.com"
]
},
{
"path": [
"/*"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.host}"
]
}
}
},
"upstreams": [
{
"dial": "tcp/index-gui:3000"
}
]
}
],
"match": [
{
"path": [
"/*"
]
}
]
}
]
}
]
},
{
"match": [
{
"host": [
"index.torrust-demo.com"
]
},
{
"path_regexp": {
"pattern": "/.well-known/acme-challenge"
}
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "file_server",
"root": "/var/www/html"
}
],
"match": [
{
"path_regexp": {
"pattern": "/.well-known/acme-challenge"
}
},
{
"remote_ip": {
"ranges": [
"0.0.0.0:0",
"::/0"
]
}
}
]
}
]
}
]
},
{
"match": [
{
"host": null
}
],
"handle": [
{
"handler": "file_server",
"index_names": [
"index.html",
"index.htm",
"index.nginx-debian.html"
],
"root": "/var/www/html"
}
]
},
{
"match": [
{
"host": [
"tracker.torrust-demo.com"
]
},
{
"path": [
"/api/*"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.host}"
]
}
}
},
"upstreams": [
{
"dial": "tcp/tracker:1212"
}
]
}
],
"match": [
{
"path": [
"/api/*"
]
}
]
}
]
}
]
},
{
"match": [
{
"host": [
"tracker.torrust-demo.com"
]
},
{
"path": [
"/*"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.host}"
]
}
}
},
"upstreams": [
{
"dial": "tcp/tracker:7070"
}
]
}
],
"match": [
{
"path": [
"/*"
]
}
]
}
]
}
]
},
{
"match": [
{
"host": [
"tracker.torrust-demo.com"
]
},
{
"path_regexp": {
"pattern": "/.well-known/acme-challenge"
}
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "file_server",
"root": "/var/www/html"
}
],
"match": [
{
"path_regexp": {
"pattern": "/.well-known/acme-challenge"
}
},
{
"remote_ip": {
"ranges": [
"0.0.0.0:0",
"::/0"
]
}
}
]
}
]
}
]
}
]
}
}
}
}
}
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.