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;
}
}
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;
}
}
编辑回复