-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf.example
More file actions
52 lines (46 loc) · 1.76 KB
/
nginx.conf.example
File metadata and controls
52 lines (46 loc) · 1.76 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
# 适用于 research-radar 项目的 Nginx 配置模板
# 复制到 /etc/nginx/sites-available/research-radar 并根据实际情况调整
server {
listen 80;
server_name example.com; # TODO: 替换为你的域名或公网IP
# 静态资源优化(可选,Next.js 生产环境一般由 3000 端口服务静态资源)
# location ~* ^/(favicon\.ico|robots\.txt|.*\.(svg|png|jpg|jpeg|gif|css|js|ico|woff2?|ttf|eot))$ {
# root /path/to/your/frontend/public; # 如有单独静态资源目录可启用
# try_files $uri @nextjs;
# access_log off;
# expires 30d;
# }
# 后端 API 代理
location ^~ /api/ {
proxy_pass http://127.0.0.1:8000/api/;
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;
}
# FastAPI 文档页面
location /docs {
proxy_pass http://127.0.0.1:8000/docs;
proxy_set_header Host $host;
}
location /redoc {
proxy_pass http://127.0.0.1:8000/redoc;
proxy_set_header Host $host;
}
# 其余全部交给 Next.js 前端
location / {
proxy_pass http://127.0.0.1:3000;
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;
}
}
# 使用 HTTPS 时,建议用 certbot 自动生成 443 配置
# server {
# listen 443 ssl;
# server_name example.com;
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# ...(其余配置同上)
# }