Docker化部署:多阶段构建 + docker-compose 编排;删除开发/内置服务器脚本;安全加固

This commit is contained in:
Fei-Qing committed 2026-06-24 19:22:26 +08:00
1 parent 044e526c80
commit af98618810
15 files changed
+424 -127

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/public;
index index.php index.html;
client_max_body_size 20M;
# 前端 SPA fallback
location / {
try_files $uri $uri/ /index.html;
}
# API 路由
location /api/ {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param HTTP_AUTHORIZATION $http_authorization;
fastcgi_hide_header X-Powered-By;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# 安全:禁止访问敏感文件
location ~ /\. {
deny all;
}
location ~* \.(env|sql|log|md|gitignore)$ {
deny all;
}
location ~* ^/(storage/cache|storage/logs)/ {
deny all;
}
# 禁止访问源代码目录
location ~* ^/(app|config|routes|database|vendor)/ {
deny all;
return 404;
}
}