1
2
3
4
5
6
7
8
9
10
11
12
13
mv caddy /usr/bin/

caddy version

groupadd --system caddy

useradd --system \
--gid caddy \
--create-home \
--home-dir /var/lib/caddy \
--shell /usr/sbin/nologin \
--comment "Caddy web server" \
caddy

/etc/systemd/system/caddy.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[Unit]
Description=caddy

[Service]
#工作目录
WorkingDirectory=/opt/caddy
PrivateTmp=true
Restart=always
Type=simple
#启动命令 前面的路径是jre的路径 后面指定的是配置文件路径
ExecStart=caddy run --environ --config /opt/caddy/Caddyfile
ExecReload=caddy reload --config /opt/caddy/Caddyfile
#结束命令
ExecStop=/usr/bin/kill -15 $MAINPID


[Install]
WantedBy=multi-user.target

/opt/caddy/Caddyfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
admin off
servers :443 {
protocols h1 h2 h3
}
}

:443, www.geektang.cn #your domain
tls xxxxxfff@gmail.com #your email
route {
reverse_proxy 127.0.0.1:8000 {
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
}