material_manage_system/frontend/nginx.conf
2026-09-21 14:13:30 +08:00

53 lines
1.5 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;
# 统一以 UTF-8 返回文本。字符集由 charset 指令加到各资源自身的 MIME 类型上,
# 不能再 add_header Content-Type,否则会把 js/css 的 MIME 也覆盖成 text/html。
charset utf-8;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
# Handle Vue Router (SPA)
location / {
try_files $uri $uri/ /index.html;
}
# API proxy to backend
location /api/ {
proxy_pass http://backend:8082/api/;
proxy_http_version 1.1;
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;
}
# WebSocket support
location /ws {
proxy_pass http://backend:8082/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
# Uploaded files
location /uploads/ {
proxy_pass http://backend:8082/uploads/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# Static assets caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}