nginx静态缓存
虚拟主机配置文件加入以下配置:
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ #不记录此类文件并且缓存15天
{
access_log off;
expires 15d;
}
location ~ \.(js|css) #不记录此类文件并且缓存2小时
{
access_log off;
expires 2h;
}
nginx配置防盗链
配置虚拟主机文件添加以下配置
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|rar|zip|gz|bz2)$ #针对这些文件进行防盗链配置
{
access_log off;
expires 15d;
valid_referers none blocked *.yanghao.com *.yangqiding.com *.yangteng.com; #只允许这几个域名
if ($invalid_referer)
{
return 403;
}
}
nginx访问控制
配置虚拟主机文件添加以下配置
location ~ .*admin\.php$ {
# auth_basic "yangqiding auth";
# auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
allow 192.168.238.1; #对于admin.php这个文件只允许192.168.238.1这个来访IP访问
deny all;
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
虚拟主机配置文件加入以下配置:
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ #不记录此类文件并且缓存15天
{
access_log off;
expires 15d;
}
location ~ \.(js|css) #不记录此类文件并且缓存2小时
{
access_log off;
expires 2h;
}
nginx配置防盗链
配置虚拟主机文件添加以下配置
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|rar|zip|gz|bz2)$ #针对这些文件进行防盗链配置
{
access_log off;
expires 15d;
valid_referers none blocked *.yanghao.com *.yangqiding.com *.yangteng.com; #只允许这几个域名
if ($invalid_referer)
{
return 403;
}
}
nginx访问控制
配置虚拟主机文件添加以下配置
location ~ .*admin\.php$ {
# auth_basic "yangqiding auth";
# auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
allow 192.168.238.1; #对于admin.php这个文件只允许192.168.238.1这个来访IP访问
deny all;
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
编辑回复