live-forum/server/admin/ZrAdminNetCore/ZR.Vue/nginx.conf
zpc 1e52b99988
All checks were successful
continuous-integration/drone/push Build is passing
21
2026-03-31 23:21:01 +08:00

61 lines
1.9 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 /usr/share/nginx/html;
index index.html;
client_max_body_size 50m;
# 开启gzip压缩
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
# ========== 反向代理到后端 API ==========
# 部署时替换此文件,修改 proxy_pass 指向实际后端地址即可
# SignalR WebSocket/api/msghub -> /msghub
location /api/msghub {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://admin-api:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
# 通用 API 代理(/api/xxx -> /xxx
location /api/ {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://admin-api: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;
client_max_body_size 50m;
}
# ========== 前端静态资源 ==========
# 处理Vue Router的history模式
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# 安全头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# 错误页面
error_page 404 /index.html;
}