nginx.conf 711 B

1234567891011121314151617181920212223242526272829303132
  1. server {
  2. listen 80;
  3. server_name _;
  4. root /usr/share/nginx/html;
  5. index index.html;
  6. # Vue Router history 模式:所有路径回退到 index.html
  7. location / {
  8. try_files $uri $uri/ /index.html;
  9. }
  10. # 静态资源长缓存
  11. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?|ttf|eot)$ {
  12. expires 30d;
  13. add_header Cache-Control "public, immutable";
  14. }
  15. # gzip 压缩
  16. gzip on;
  17. gzip_vary on;
  18. gzip_min_length 1024;
  19. gzip_types
  20. text/plain
  21. text/css
  22. text/xml
  23. text/javascript
  24. application/javascript
  25. application/json
  26. application/xml
  27. application/xml+rss
  28. image/svg+xml;
  29. }