Files
gofly-platform-services/zlt-web/react-web/src/main/frontend/nginx.conf
T

66 lines
2.2 KiB
Nginx Configuration File
Raw Normal View History

2025-03-30 22:11:50 +08:00
server {
listen 8080;
server_name localhost;
# gzip 配置
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_proxied any;
root /usr/share/nginx/html;
index index.html;
2025-04-01 08:58:58 +08:00
# 重要:确保所有路由都指向 index.html
2025-03-30 22:11:50 +08:00
location / {
try_files $uri $uri/ /index.html;
2025-04-01 08:58:58 +08:00
# 添加必要的跨域和缓存控制头
add_header Access-Control-Allow-Origin *;
add_header Cache-Control no-cache;
# 添加安全相关头
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
2025-03-30 22:11:50 +08:00
}
# API-UAA 服务代理
location /api-uaa/ {
proxy_pass http://119.45.169.13:9900/api-uaa/; # 替换为实际的后端地址
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
2025-04-01 08:58:58 +08:00
# 添加跨域支持
2025-03-30 22:11:50 +08:00
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
2025-04-01 08:58:58 +08:00
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Expose-Headers '*';
2025-03-30 22:11:50 +08:00
# 处理 OPTIONS 请求
if ($request_method = 'OPTIONS') {
return 204;
}
}
# 其他 API 服务代理(如果需要)
location /api/ {
proxy_pass http://119.45.169.13:9900/; # 替换为实际的后端地址
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 添加跨域头
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, 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';
# 处理 OPTIONS 请求
if ($request_method = 'OPTIONS') {
return 204;
}
}
}