|
@@ -0,0 +1,33 @@
|
|
|
|
|
+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;
|
|
|
|
|
+ gzip_disable "MSIE [1-6]\.";
|
|
|
|
|
+
|
|
|
|
|
+ # 根目录配置
|
|
|
|
|
+ root /usr/share/nginx/html;
|
|
|
|
|
+ index index.html;
|
|
|
|
|
+
|
|
|
|
|
+ # 处理Vue路由(避免404)
|
|
|
|
|
+ location / {
|
|
|
|
|
+ try_files $uri $uri/ /index.html;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # 静态资源缓存
|
|
|
|
|
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
|
|
|
|
+ expires 1y;
|
|
|
|
|
+ add_header Cache-Control "public, immutable";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # 禁止访问隐藏文件
|
|
|
|
|
+ location ~ /\. {
|
|
|
|
|
+ deny all;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|