Files
ctms/nginx/nginx.conf
T
Cheng Zhou d23dead775
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
加固部署配置与敏感路径拦截
2026-06-22 15:35:48 +08:00

72 lines
1.9 KiB
Nginx Configuration File

worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
resolver 127.0.0.11 valid=10s ipv6=off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
root /usr/share/nginx/html;
index index.html;
upstream backend {
zone backend 64k;
server backend:8000 resolve;
}
server {
listen 80;
server_name _;
client_max_body_size 20m;
location = /favicon.ico {
root /usr/share/nginx/html;
try_files /favicon.ico =204;
access_log off;
log_not_found off;
expires 1d;
add_header Cache-Control "public, max-age=86400" always;
}
location ~* (^|/)(\.git|\.env($|[./_-])|wp-config\.php|config\.php|database\.yml|backup($|[._/-])) {
access_log off;
log_not_found off;
return 404;
}
location /api/ {
proxy_pass http://backend;
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 /health {
proxy_pass http://backend;
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 / {
try_files $uri $uri/ /index.html;
}
}
}