nginx虚拟主机配置文件

回复 收藏
vim /usr/local/nginx/conf/vhosts/default.conf
server
{
  listen 80 ;
  server_name
www.test.com www.aaa.com www.bbb.com;
  if ($host != 'www.test.com' )
       {
         rewrite  ^/(.*)$  
http://www.test.com/$1  permanent;
        }
  index index.html index.htm index.php;
  root /data/www;
  access_log /tmp/access.log combined_realip;
  if ($http_user_agent ~* 'baidu|111111')
  {
     return 403;
   }
   location ~ .*admin\.php$ {
    #allow 192.168.1.103;
    #deny all;
    auth_basic "chao auth";
    auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
    include fastcgi_params;
    #fastcgi_pass unix:/tmp/php-fcgi.sock;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

    }
   location ~ ,*\.(gif|png|bmp|swf|jpg|jpeg|flv|rar|zip|gz|bz2)$ {
      access_log off;
      expires 15d;
      valid_referers none blocked   *.test.com *.aaa.com';
      if ($invalid_referer)
        {
          return 403;
          }
    }
   location ~\.(js|css)
   {
    access_log off;
    expires 2h;
    }
   location ~ (static|cache)
   {
     access_log off;
    }
   location ~ \.php$ {
   include fastcgi_params;
   #fastcgi_pass unix:/tmp/php-fcgi.sock;
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

    }
}

2016-03-01 14:57 举报
已邀请:
0

fansze

赞同来自:

bucuo
0

Linuxpp

赞同来自:

good

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: