liyeho 发表于 2017-12-23 22:51:17

nginx常用配置系列-静态资源处理

server {  listen       80;
  server_nameexample.com;
  index index.html index.htm index.php index.do;
  #站点根目录   
  root /home/www/html/resources;
  # 配置nginx动静分离,定义的静态页面直接从nginx发布目录读取。
  location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
  {
  root /home/www/html/resources;
  # expires定义用户浏览器缓存的时间为30天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力
  expires      30d;
  # 关闭访问日志
  access off;
  }
  
}
页: [1]
查看完整版本: nginx常用配置系列-静态资源处理