初始化提交
This commit is contained in:
36
docker/nginx.conf
Normal file
36
docker/nginx.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
server {
|
||||
listen 7878;
|
||||
server_name _;
|
||||
root /app/frontend/dist;
|
||||
index index.html;
|
||||
|
||||
# 静态内容优先走前端
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html @backend;
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
}
|
||||
|
||||
# 后端 API 代理
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
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;
|
||||
}
|
||||
|
||||
# 兜底转发到后端(短链跳转)
|
||||
location @backend {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
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;
|
||||
}
|
||||
|
||||
# 静态资源缓存策略
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
20
docker/start.sh
Normal file
20
docker/start.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 如果持久化目录中有数据文件,使用它;否则创建新的
|
||||
if [ -f /shumengya/docker/storage/mengyalinkfly/link_data.json ]; then
|
||||
echo "使用持久化的数据文件..."
|
||||
ln -sf /shumengya/docker/storage/mengyalinkfly/link_data.json /app/backend/link_data.json
|
||||
else
|
||||
echo "创建新的数据文件..."
|
||||
echo '{}' > /shumengya/docker/storage/mengyalinkfly/link_data.json
|
||||
ln -sf /shumengya/docker/storage/mengyalinkfly/link_data.json /app/backend/link_data.json
|
||||
fi
|
||||
|
||||
# 启动 nginx
|
||||
echo "启动 Nginx..."
|
||||
nginx
|
||||
|
||||
# 启动 Flask 后端(使用 gunicorn)
|
||||
echo "启动 Flask 后端..."
|
||||
cd /app/backend
|
||||
exec gunicorn -w 4 -b 0.0.0.0:5000 app:app
|
||||
Reference in New Issue
Block a user