73 lines
1.9 KiB
Nginx Configuration File
73 lines
1.9 KiB
Nginx Configuration File
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
|
||
#access_log /var/log/nginx/host.access.log main;
|
||
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
# 缓存静态资源
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||
expires 1y;
|
||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||
}
|
||
|
||
# API请求代理到后端服务
|
||
location /api/ {
|
||
proxy_pass ${BACKEND_URL}/api/;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection 'upgrade';
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
proxy_read_timeout 300s;
|
||
}
|
||
|
||
location /login {
|
||
proxy_pass ${BACKEND_URL}/login;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
}
|
||
|
||
location /check_auth {
|
||
proxy_pass ${BACKEND_URL}/check_auth;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
}
|
||
|
||
location /need_login {
|
||
proxy_pass ${BACKEND_URL}/need_login;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
}
|
||
|
||
location /config {
|
||
proxy_pass ${BACKEND_URL}/config;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
}
|
||
|
||
location /analyze {
|
||
proxy_pass ${BACKEND_URL}/analyze;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_cache_bypass $http_upgrade;
|
||
proxy_read_timeout 300s;
|
||
}
|
||
|
||
# 所有其他路由返回index.html(SPA应用需要)
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 错误页面
|
||
error_page 500 502 503 504 /50x.html;
|
||
location = /50x.html {
|
||
root /usr/share/nginx/html;
|
||
}
|
||
} |