server {
       #开放端口
        listen 80;
        
		#站点域名
		server_name demo.com;
	
		#默认访问文件
		index index.php;
        
		#站点根路径
		root /data/www/demo;
		
		#访问日志
		access_log      /data/logs/demo.log;
		
		error_page  500  /500.html;
		error_page  502  /500.html;
		error_page  404  /404.html;

	    if ($http_user_agent ~* "Baiduspider") {
	        return 403;
	    }

	    if ($http_user_agent ~* "bingbot") {
	        return 403;
	    }

	    if ($http_user_agent ~* "sogou") {
	        return 403;
	    }

	    if ($http_user_agent ~* "google") {
	        return 403;
	    }

	    if ($http_user_agent ~* "Yahoo") {
	        return 403;
	    }

	    if  ($request_uri  ~* "/thread") {
	        return 403;
	    }

	    if  ($request_uri  ~* "/forum-") {
	        return 403;
	    }

	    if  ($request_uri  ~* "/thread-") {
	        return 403;
	    }
		
		#对php ci框架控制器支持
		location / {
			#配置htpasswd密码
			#auth_basic            "QQ:800107629";
			#auth_basic_user_file  /data/nginx/conf/first;

			if (!-e $request_filename) {
				
				#设置默认访问的php文件
				rewrite ^/(.*)$ /index.php?$1 last;
				break;
			}
		}

		#对PHP支持
        location ~ .*\.php?$ {
		    root /data/www/demo;
            fastcgi_pass 127.0.0.1:9000;
			
            set $path_info "";
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$"){
                 set $real_script_name $1;
                 set $path_info $2;
            }
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            #fastcgi_param PATH_INFO $path_info;
			include fastcgi_params;
            fastcgi_param CI_ENV production;
        }

        location ~ .*\.(png|jpeg|jpg|gif|ico)$ {
            expires 30d;
        }

        location ~ .*\.(js|css)?$ {
            expires 1d;
        }
}
