-
Notifications
You must be signed in to change notification settings - Fork 463
Expand file tree
/
Copy pathnginx.conf
More file actions
46 lines (38 loc) · 1.47 KB
/
nginx.conf
File metadata and controls
46 lines (38 loc) · 1.47 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
server {
listen 443 ssl;
server_name domain.com;
charset utf-8;
ssl_certificate /home/cert/tvcertificate.crt;
ssl_certificate_key /home/cert/tvprivate.pem;
location / {
proxy_pass http://ip:3003;
# 重要的代理头信息,让 Next.js 服务器知道原始请求的来源
proxy_set_header Host $host; # 原始主机名
proxy_set_header X-Real-IP $remote_addr; # 客户端真实 IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 代理链
proxy_set_header X-Forwarded-Proto $scheme; # 原始协议 (http/https)
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
}
location /ws-api {
proxy_pass http://ip:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket 特定的超时设置(长连接)
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
# 禁用缓冲以减少延迟
proxy_buffering off;
}
}
server {
listen 80;
server_name domain.com;
return 301 https://domain.com$request_uri;
}