\fix: final nginx hardening and docker setup"
This commit is contained in:
1 parent
2f12ae684b
commit
e6907d3ed7
4 files changed
+21
-14
No files matched your search
@@ -37,9 +37,10 @@ if (!fs.existsSync(CHUNK_DIR)) {
|
||||
console.log(`📁 创建分块目录: ${CHUNK_DIR}`);
|
||||
}
|
||||
|
||||
// 中间件
|
||||
// 中间件 (允许全域访问以协助调试,生产稳定后可缩减)
|
||||
app.use(cors({
|
||||
origin: process.env.CORS_ORIGIN || '*',
|
||||
origin: true, // 允许所有来源
|
||||
credentials: true,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
||||
allowedHeaders: ['Content-Type', 'X-API-Key', 'X-Upload-Id', 'X-Chunk-Index', 'Authorization'],
|
||||
}));
|
||||
|
||||
@@ -3,6 +3,7 @@ version: '3.8'
|
||||
services:
|
||||
# 前端(暴露到宿主机供 Nginx 反代)
|
||||
frontend:
|
||||
image: cxaryoro/foomclous-frontend
|
||||
build:
|
||||
context: ./frontend
|
||||
args:
|
||||
@@ -16,6 +17,7 @@ services:
|
||||
|
||||
# 后端(暴露到宿主机供 Nginx 反代)
|
||||
backend:
|
||||
image: cxaryoro/foomclous-backend
|
||||
build: ./backend
|
||||
container_name: foomclous-backend
|
||||
ports:
|
||||
|
||||
+15
-12
@@ -17,18 +17,10 @@ server {
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# 静态资源缓存
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# SPA 路由支持
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# API 代理 (使用 ^~ 确保高优先级)
|
||||
# [重要] 优先处理 API 和 静态资源代理 (放在最前面保证高优先级)
|
||||
# 使用 ^~ 确保如果匹配到这些路径,就不再检查正则表达式路径
|
||||
|
||||
# API 代理
|
||||
location ^~ /api {
|
||||
proxy_pass http://backend:51947;
|
||||
proxy_http_version 1.1;
|
||||
@@ -48,4 +40,15 @@ server {
|
||||
location ^~ /thumbnails {
|
||||
proxy_pass http://backend:51947;
|
||||
}
|
||||
|
||||
# 静态资源缓存 (放在代理之后)
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# SPA 路由支持 (放在最后作为兜底)
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ const getApiBase = () => {
|
||||
};
|
||||
|
||||
const API_BASE = getApiBase();
|
||||
console.log('🚀 FoomClous API_BASE:', API_BASE || '(relative path)');
|
||||
|
||||
// 分块大小:50MB(小于 Cloudflare 100MB 限制)
|
||||
const CHUNK_SIZE = 50 * 1024 * 1024;
|
||||
|
||||
Reference in new issue
Block a user