70 lines
1.9 KiB
Plaintext
70 lines
1.9 KiB
Plaintext
# Nginx配置文件 - 测试环境
|
|
# 用于Vue3前端静态文件服务和API代理
|
|
|
|
server {
|
|
listen 80;
|
|
server_name staging.anxin.com localhost;
|
|
|
|
# 测试环境日志配置
|
|
access_log /var/log/nginx/access.log;
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
# 安全头配置
|
|
add_header X-Frame-Options DENY;
|
|
add_header X-Content-Type-Options nosniff;
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
|
|
|
# 静态文件服务
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
# 测试环境缓存配置
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
|
expires 1d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
location ~* \.(html)$ {
|
|
expires 1h;
|
|
add_header Cache-Control "public";
|
|
}
|
|
}
|
|
|
|
# API代理到后端服务
|
|
location /prod-api/ {
|
|
proxy_pass http://anxin-backend:8080/;
|
|
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;
|
|
|
|
# 测试环境代理配置
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
proxy_buffering on;
|
|
proxy_buffer_size 4k;
|
|
proxy_buffers 8 4k;
|
|
|
|
# 限制请求大小
|
|
client_max_body_size 10m;
|
|
}
|
|
|
|
# 健康检查端点
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# 测试环境状态页面
|
|
location /nginx_status {
|
|
stub_status on;
|
|
access_log off;
|
|
allow 172.22.0.0/16;
|
|
deny all;
|
|
}
|
|
} |