-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaddyfile
More file actions
72 lines (65 loc) · 1.78 KB
/
Copy pathCaddyfile
File metadata and controls
72 lines (65 loc) · 1.78 KB
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
70
71
72
{
log {
output file /var/log/caddy/access.log
level INFO
}
admin off
}
:80 {
root * /var/www/html
file_server
# SPA 路由处理 - 将所有非 API、非静态资源的请求重写到 index.html
@spa {
not path /api/*
not path /ws/*
not path /health
not path /_nuxt/*
not path /favicon*
not path *.ico
not path *.css
not path *.js
not path *.png
not path *.jpg
not path *.svg
not path *.woff*
not path *.ttf
not path *.eot
}
handle @spa {
rewrite * /index.html
}
# API 代理配置
reverse_proxy /api/* localhost:8080 {
header_up Host {http.reverse_proxy.upstream.hostport}
header_up X-Real-IP {http.request.remote_host}
header_up X-Forwarded-For {http.request.remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Port {port}
# 超时配置
transport http {
dial_timeout 30s
read_timeout 30s
write_timeout 30s
}
}
# WebSocket 代理配置
reverse_proxy /ws/* localhost:8080 {
header_up Host {http.reverse_proxy.upstream.hostport}
header_up X-Real-IP {http.request.remote_host}
header_up X-Forwarded-For {http.request.remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Port {port}
# WebSocket 长连接超时
transport http {
dial_timeout 30s
read_timeout 86400s # 24小时
write_timeout 86400s # 24小时
}
}
# 健康检查端点
handle /health {
respond "healthy" 200
}
}