68 lines
1.7 KiB
Nginx Configuration File
68 lines
1.7 KiB
Nginx Configuration File
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name localhost;
|
||
|
|
|
||
|
|
# 设置客户端最大上传文件大小
|
||
|
|
client_max_body_size 20M;
|
||
|
|
|
||
|
|
# Gzip压缩
|
||
|
|
gzip on;
|
||
|
|
gzip_vary on;
|
||
|
|
gzip_min_length 1024;
|
||
|
|
gzip_proxied any;
|
||
|
|
gzip_comp_level 6;
|
||
|
|
gzip_types
|
||
|
|
text/plain
|
||
|
|
text/css
|
||
|
|
text/xml
|
||
|
|
text/javascript
|
||
|
|
application/json
|
||
|
|
application/javascript
|
||
|
|
application/xml+rss
|
||
|
|
application/atom+xml
|
||
|
|
image/svg+xml;
|
||
|
|
|
||
|
|
# 缓存静态资源
|
||
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||
|
|
expires 1y;
|
||
|
|
add_header Cache-Control "public, immutable";
|
||
|
|
}
|
||
|
|
|
||
|
|
# 前端路由
|
||
|
|
location / {
|
||
|
|
root /usr/share/nginx/html;
|
||
|
|
index index.html index.htm;
|
||
|
|
try_files $uri $uri/ /index.html;
|
||
|
|
}
|
||
|
|
|
||
|
|
# API代理到后端
|
||
|
|
location /api {
|
||
|
|
proxy_pass http://backend:5000;
|
||
|
|
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_connect_timeout 60s;
|
||
|
|
proxy_send_timeout 60s;
|
||
|
|
proxy_read_timeout 60s;
|
||
|
|
}
|
||
|
|
|
||
|
|
# 文件下载代理
|
||
|
|
location /api/files {
|
||
|
|
proxy_pass http://backend:5000;
|
||
|
|
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_max_temp_file_size 1024m;
|
||
|
|
proxy_buffering off;
|
||
|
|
}
|
||
|
|
|
||
|
|
# 错误页面
|
||
|
|
error_page 404 /index.html;
|
||
|
|
error_page 500 502 503 504 /index.html;
|
||
|
|
}
|