1. Output of caddy version
:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
2. How I run Caddy:
/usr/bin/caddy run --environ --resume --config /etc/caddy/caddyfile.json
a. System environment:
Ubuntu 22.04, systemd
b. Command:
systemctl start caddy
c. Service/unit/compose file:
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --resume --config /etc/caddy/caddyfile.json
ExecReload=/usr/bin/caddy reload --config /etc/caddy/caddyfile.json --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateDevices=yes
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
I’m so sorry, I replaced domain name because of security reasons yet
{
"apps": {
"http": {
"servers": {
"MyServer": {
"listen": [
":443"
],
"routes": [
{
"@id": "domain1",
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"@id": "app_routes",
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "http",
"read_buffer_size": 4096
},
"upstreams": [
{
"dial": "127.0.0.1:8017"
}
]
}
],
"match": [
{
"path": [
"app1"
]
}
]
}
]
}
],
"match": [
{
"path": [
"/s/*"
]
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "http",
"read_buffer_size": 4096
},
"upstreams": [
{
"dial": "127.0.0.1:8080"
}
]
}
]
}
]
}
],
"match": [
{
"host": [
"mymaskedaddress.com"
]
}
]
}
]
}
}
}
},
"logging": {
"logs": {
"": {
"level": "",
"sampling": {
"first": 0,
"interval": 0,
"thereafter": 0
},
"writer": {
"filename": "/var/log/caddy/caddy.log",
"output": "file",
"roll": true,
"roll_gzip": true,
"roll_keep": 10,
"roll_keep_days": 365,
"roll_local_time": false,
"roll_size_mb": 4
}
}
}
}
}
3. The problem I’m having:
I have multiple applications main, app1, app2 … etc. Main app is OK and it works on mymaskedaddress.com/, so I also want to make app1 and app2 to work behind reverse proxy with respective path like these: app1 on mymaskedaddress.com/s/app1 and app2 on mymaskedaddress.com/s/app2. so how can I do that within caddyfile.json?
4. Error messages and/or full log output:
I’m just getting 404 for mymaskedaddress.com/s/app1
5. What I already tried:
I tried to do that with adding subroute into caddyfile.json but I cannot make subapps work
6. Links to relevant resources:
Caddy’s official docs