forked from wangqifan/calc
46 lines
1.2 KiB
Nginx Configuration File
46 lines
1.2 KiB
Nginx Configuration File
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name localhost;
|
||
|
|
|
||
|
|
root /usr/share/nginx/html;
|
||
|
|
index index.html;
|
||
|
|
|
||
|
|
# gzip配置
|
||
|
|
gzip on;
|
||
|
|
gzip_min_length 1k;
|
||
|
|
gzip_comp_level 6;
|
||
|
|
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
||
|
|
gzip_vary on;
|
||
|
|
gzip_disable "MSIE [1-6]\.";
|
||
|
|
|
||
|
|
# 缓存配置
|
||
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||
|
|
expires 30d;
|
||
|
|
add_header Cache-Control "public, no-transform";
|
||
|
|
}
|
||
|
|
|
||
|
|
# 路由配置
|
||
|
|
location / {
|
||
|
|
try_files $uri $uri/ /index.html;
|
||
|
|
}
|
||
|
|
|
||
|
|
# API代理配置
|
||
|
|
location /api {
|
||
|
|
proxy_pass http://backend:8000;
|
||
|
|
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_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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# 错误页面配置
|
||
|
|
error_page 404 /index.html;
|
||
|
|
error_page 500 502 503 504 /50x.html;
|
||
|
|
location = /50x.html {
|
||
|
|
root /usr/share/nginx/html;
|
||
|
|
}
|
||
|
|
}
|