anxin-ruoyi/docker/configs/nginx.conf.dev
2026-01-05 01:46:20 +08:00

62 lines
1.9 KiB
Plaintext

# Nginx配置文件 - 开发环境
# 用于Vue3前端静态文件服务和API代理
server {
listen 80;
server_name localhost;
# 开发环境特有配置
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
# 静态文件服务
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
# 开发环境禁用缓存
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# 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 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_buffering off;
# CORS配置用于开发环境
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
}
# 开发工具代理 (如果需要)
location /sockjs-node/ {
proxy_pass http://anxin-frontend:24678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# 健康检查端点
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}