30 lines
746 B
Nginx Configuration File
30 lines
746 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# 开启gzip
|
|
gzip on;
|
|
gzip_min_length 1k;
|
|
gzip_comp_level 9;
|
|
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
|
gzip_vary on;
|
|
|
|
# 资源文件缓存
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
|
root /usr/share/nginx/html;
|
|
expires 1d;
|
|
}
|
|
|
|
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;
|
|
}
|
|
} |