mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-30 03:48:03 +08:00
120 lines
3.3 KiB
Plaintext
120 lines
3.3 KiB
Plaintext
|
|
# 前端发布包统一从 /public 提供
|
|
root /public;
|
|
|
|
# 主应用路由
|
|
location / {
|
|
expires off;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 本地CookieCloud
|
|
location /cookiecloud {
|
|
error_log /dev/null crit;
|
|
|
|
proxy_pass http://backend_api;
|
|
rewrite ^.+mock-server/?(?<suffix>.*)$ /$suffix break;
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_redirect off;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Nginx-Proxy true;
|
|
|
|
proxy_read_timeout 600s;
|
|
}
|
|
|
|
# 事件流保持长连接,及时转发增量内容
|
|
location ~ ^/api/v1/(system/(message|progress/|logging)|search/.*/stream$|message/agent/stream$) {
|
|
error_log /dev/null crit;
|
|
|
|
default_type text/event-stream;
|
|
|
|
# 禁止缓存、压缩和代理缓冲,避免事件被攒成一批后才到达客户端。
|
|
add_header Cache-Control "no-cache, no-transform";
|
|
add_header X-Accel-Buffering no;
|
|
gzip off;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
proxy_pass http://backend_api;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
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_read_timeout 3600s;
|
|
}
|
|
|
|
# API代理配置
|
|
location /api {
|
|
error_log /dev/null crit;
|
|
|
|
proxy_pass http://backend_api;
|
|
rewrite ^.+mock-server/?(?<api_path>.*)$ /$api_path break;
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_redirect off;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Nginx-Proxy true;
|
|
|
|
proxy_read_timeout 600s;
|
|
}
|
|
|
|
# 图片类静态资源
|
|
location ~* \.(png|jpg|jpeg|gif|ico|svg)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Service Worker 和 Web App Manifest 需要稳定 URL 但不能长缓存,否则前端更新时浏览器可能继续注册旧版本。
|
|
location = /service-worker.js {
|
|
expires off;
|
|
add_header Cache-Control "no-cache, must-revalidate";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location = /manifest.webmanifest {
|
|
expires off;
|
|
default_type application/manifest+json;
|
|
add_header Cache-Control "no-cache, must-revalidate";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# JS 和 CSS 静态资源缓存(排除 /api/v1 路径)
|
|
location ~* ^/(?!api/v1).*\.(js|css)$ {
|
|
try_files $uri =404;
|
|
expires 30d;
|
|
add_header Cache-Control "public";
|
|
add_header Vary Accept-Encoding;
|
|
}
|
|
|
|
# 前端静态资源允许长期缓存
|
|
location /assets {
|
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
}
|
|
|
|
# 站点图标
|
|
location /api/v1/site/icon/ {
|
|
error_log /dev/null crit;
|
|
|
|
proxy_cache my_cache;
|
|
proxy_cache_valid 200 302 1h;
|
|
proxy_cache_valid any 5m;
|
|
proxy_cache_key "$scheme$request_method$host$request_uri";
|
|
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
|
|
|
proxy_pass http://backend_api;
|
|
}
|