海运的博客

Nginx判断accept_language禁止英文浏览器/操作系统访问

发布时间:June 27, 2012 // 分类:Nginx // No Comments

HTTP协议发送请求时会附加accept_language,通过它可知道浏览器所支持的语言,一般也为操作系统默认的语言。
列举一些accept_language标识:

zh 中文
zh-cn 大陆
zh-tw 台湾
zh-hk 香港
en 英文

配置Nginx允许中文用户访问,拒绝其它语言用户访问。

if ( $http_accept_language ~* ^[^zh])
{
return 404; #非中文用户访问网站返回404
}

Curl测试:

curl -I -H "Accept-Language:en"  www.haiyun.me
HTTP/1.1 404 Not Found
Date: Wed, 20 Jun 2012 18:38:33 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive

Awstats分析Nginx和IIS日志

发布时间:June 23, 2012 // 分类:日记分析 // No Comments

Awstat默认支持Apache日记格式,IISNginx需修改日志记录格式 。
IIS自定义日志格式为:

#https://www.haiyun.me
date
time
c-ip
cs-username
cs-method
cs-uri-stem
cs-uri-query
sc-status
sc-bytes
cs-version
cs(User-Agent)
cs(Referer)

然后配置文件日记类型更改为2,1为Apache

LogFormat=1

2.Nginx调整日志为Apache格式:

#https://www.haiyun.me
log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';

Apache/PHP/Mysql/Nginx编译参数查看

发布时间:June 20, 2012 // 分类:Apache,Nginx,PHP,数据库 // No Comments

查看Nginx编译参数:

/usr/local/nginx/sbin/nginx -V

查看Apache编译参数:

cat /usr/local/apache/build/config.nice

查看PHP编译参数:

/usr/local/php/bin/php -i |grep configure

查看Mysql编译参数:

cat /usr/local/mysql/bin/mysqlbug|grep configure

Nginx设置防止恶意域名指向IP

发布时间:June 2, 2012 // 分类:Nginx // No Comments

Nginx默认虚拟主机在用户通过IP访问,或者通过未设置的域名访问(比如有人把他自己的域名指向了你的ip)的时候生效,默认为第一个Server段的虚拟主机,可通过设置指定默认虚拟主机:

server {
listen     80 default; #default表示默认虚拟主机,未知域名或通过IP访问 
rewrite ^(.*) https://www.haiyun.me permanent; #301重定向到自己的网站
#return 404; #返回相应的状态码
#return 403;
#return 500;
}

Nginx根据来路、UA和访客IP做访问控制

发布时间:June 2, 2012 // 分类:Nginx // No Comments

Nginx配置判断来路referer如果为*.www.haiyun.me返回403:

if ($http_referer ~* .*\.www.haiyun.me){
return 403;
}

判断用户user_agent如果为NSPlayer返回403:

if ($http_user_agent ~* NSPlayer.*){
return 403;
}

根据访客IP做限制:

if ($remote_addr != "192.168.1.5"){
    return 403;
}   
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...