Files
ecs-controller/docker/nginx.conf

56 lines
1.3 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html;
# 日志输出到 stdout/stderr由 Docker 收集
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
# Gzip 压缩
gzip on;
gzip_types text/css application/javascript application/json text/plain;
gzip_min_length 1000;
gzip_vary on;
# 静态资源缓存
location /static/ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# 处理前端路由
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# 处理 PHP 请求
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;
}
# 安全配置:禁止访问 .ht* 文件
location ~ /\.ht {
deny all;
}
# 安全配置:严禁外部直接访问 SQLite 数据库文件及 data 目录
location ^~ /data/ {
deny all;
return 403;
}
# 禁止访问 git 文件
location ~ /\.git {
deny all;
}
# 禁止访问 composer 文件
location ~ /composer\.(json|lock) {
deny all;
}
}