- FastAPI 后端: REST API + Bearer Token 鉴权 + PDF 代理 - 180 篇论文数据 (data/papers.json): 9 模块、32 子领域 - 前端: 数据驱动、卡片径向渐变光效、PDF 页面内阅读 - 底部状态栏: arXiv/HF 连通性检测 - PDF 加载: arXiv 优先(5s超时) → HK 本地兜底 - Docker 化部署 (Dockerfile + start.sh + nginx.conf) - arXiv + HF 批量下载器 (api/downloader.py)
56 lines
1.6 KiB
Nginx Configuration File
56 lines
1.6 KiB
Nginx Configuration File
# LLM 论文图书馆 — Nginx 反向代理配置
|
|
# 部署路径: /etc/nginx/sites-available/llm-library
|
|
|
|
server {
|
|
listen 80;
|
|
server_name your-domain.com;
|
|
|
|
# 安全头
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "no-referrer" always;
|
|
|
|
# 限制请求速率 (防止滥用)
|
|
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
|
|
|
|
# API 代理
|
|
location /api/ {
|
|
proxy_pass http://127.0.0.1:8000;
|
|
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;
|
|
limit_req zone=api burst=20 nodelay;
|
|
}
|
|
|
|
# PDF 代理 — 强制 inline 阻止 IDM 弹下载
|
|
location /papers/ {
|
|
proxy_pass http://127.0.0.1:8741;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_read_timeout 60s;
|
|
# 追加 inline header 防止 IDM 拦截
|
|
add_header Content-Disposition "inline" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
}
|
|
|
|
# 静态文件直接由 Nginx 服务 (性能更好)
|
|
location /style.css {
|
|
alias /opt/llm-library/static/style.css;
|
|
expires 1d;
|
|
}
|
|
location /app.js {
|
|
alias /opt/llm-library/static/app.js;
|
|
expires 1d;
|
|
}
|
|
location /favicon.ico {
|
|
return 204;
|
|
}
|
|
|
|
# 首页
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8000;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|