Chinaunix首页 | 论坛 | 博客
  • 博客访问: 295644
  • 博文数量: 47
  • 博客积分: 1667
  • 博客等级: 上尉
  • 技术积分: 686
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 16:20
文章分类

全部博文(47)

文章存档

2013年(20)

2012年(20)

2011年(7)

分类: LINUX

2013-03-15 17:04:09

nginx.conf 可以使用变量

例1: 我的video 下面都是以 年份-月份-日期格式的文件夹,如2013-03-11

现在我的服务器硬盘满了,也不能插硬盘了,想把 2012年的文件夹通过NFS方式移动到另外一个服务器上,然后挂载到服务器上/var/www2/video目录下,原来的文件在/var/www/video下

server {
    listen       80;
    server_name  video.manwrx.com;
    index index.html index.htm;
    set $rootdir  /var/www/videos;
    if  ($request_uri ~* ^/2012(.*)){
      set $rootdir /var/www2/video;
}


  root $rootdir;
  # error_log   /tmp/error_log debug;

 location ~ \.flv {
        flv;
    }
}


例2,因为2012年的视频文件太多了,nfs挂载的硬盘不能满足条件,想把2012年1月份的文件然仍然让在/var/www/video下面
,因为nginx 是从上往下读的配置文件,



server {
    listen       80;
    server_name  video.manwrx.com;
    index index.html index.htm;
    set $rootdir  /var/www/videos;
    if  ($request_uri ~* ^/2012(.*)){
      set $rootdir /var/www2/video;
}
if  ($request_uri ~* ^/2012-01) {
     set  $rootdir  /var/www/videos;
}

  root $rootdir;
  # error_log   /tmp/error_log debug;

 location ~ \.flv {
        flv;
    }
}
阅读(3404) | 评论(0) | 转发(0) |
0

上一篇:编写启动脚本

下一篇:git 学习

给主人留下些什么吧!~~