1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# 开始配置
mkdir -p /etc/caddy/ && touch /etc/caddy/Caddyfile
cat > /etc/caddy/Caddyfile << \EOF
{
admin off
order forward_proxy before reverse_proxy
}
:443, luodaoyi.com {
tls [email protected]
request_body {
max_size 1GB
}
forward_proxy {
basic_auth asura asura123
hide_ip
hide_via
probe_resistance
}
# 这里的端口是你反代的地址 随便你填 没的话填域名也可以
# reverse_proxy www.bing.com
reverse_proxy 127.0.0.1:33000
}
EOF
# 封装成服务 开机启动
groupadd --system caddy
useradd --system \
--gid caddy \
--create-home \
--home-dir /var/lib/caddy \
--shell /usr/sbin/nologin \
--comment "Caddy web server" \
caddy
cat > /etc/systemd/system/caddy.service << \EOF
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
EOF
# 测试正常不正常
sudo systemctl daemon-reload && sudo systemctl enable caddy
sudo systemctl start caddy && sudo systemctl status caddy
|