nginx.conf 740 B

123456789101112131415161718192021222324252627282930313233
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. # 开启gzip压缩
  5. gzip on;
  6. gzip_min_length 1k;
  7. gzip_comp_level 9;
  8. gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
  9. gzip_vary on;
  10. gzip_disable "MSIE [1-6]\.";
  11. # 根目录配置
  12. root /usr/share/nginx/html;
  13. index index.html;
  14. # 处理Vue路由(避免404)
  15. location / {
  16. try_files $uri $uri/ /index.html;
  17. }
  18. # 静态资源缓存
  19. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
  20. expires 1y;
  21. add_header Cache-Control "public, immutable";
  22. }
  23. # 禁止访问隐藏文件
  24. location ~ /\. {
  25. deny all;
  26. }
  27. }