You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
besure_web/nginx.conf

122 lines
3.9 KiB
Nginx Configuration File

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

server {
listen 8088;
server_name localhost;
# 关键允许上传最大100MB
client_max_body_size 100m;
# 超时时间
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
client_body_timeout 300s;
send_timeout 300s;
# 防止大文件上传被缓冲卡死
proxy_request_buffering off;
proxy_buffering off;
location /admin-api/ {
proxy_pass http://besure_server:48081;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api/ {
proxy_pass http://besure_server:48081;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /jmreport/ {
proxy_pass http://besure_server:48081;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /v3/api-docs/ {
proxy_pass http://besure_server:48081;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /doc.html {
proxy_pass http://besure_server:48081;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /swagger-ui/ {
proxy_pass http://besure_server:48081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 处理Swagger静态资源
location /webjars/ {
proxy_pass http://besure_server:48081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 处理API文档JSON文件
location ~ /v3/api-docs/.*\.json$ {
proxy_pass http://besure_server:48081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# Vite 将这些第三方库输出为带内容哈希的独立文件。文件内容变化时 URL 会变化,
# 因此可以长期缓存;业务代码不会匹配此规则。
location ~ ^/assets/(?:element-plus|hiprint|form-create|wangeditor|echarts|cropperjs|vue)-[A-Za-z0-9_-]+\.js$ {
root /usr/share/nginx/html;
try_files $uri =404;
add_header Cache-Control "public, max-age=31536000, immutable" always;
}
# 项目业务 JS 不使用浏览器缓存,确保每次访问均会检查线上最新版本。
location ~ ^/assets/.*\.js$ {
root /usr/share/nginx/html;
try_files $uri =404;
add_header Cache-Control "no-store, max-age=0" always;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}