nginx根据http_user_agent防DDOS
2010-12-01 11:23
453 查看
前端squid反向代理到nginx
nginx根据http_user_agent防DDOS
首先查看访问日志,找出可疑访问 找到http_user_agent 的特征,然后再作过滤
"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; MyIE 3.01)Cache-Control: no-store, must-revalidate"
if ($http_user_agent ~ must-revalidate) {
return 503;
}
#这样就返回503错误
location = / {
include proxy.conf;
if ( $http_user_agent ~* "MSIE 5.01" ) {
proxy_pass http://www.qq.com;
#access_log /usr/local/nginx/logs/k.log main;
}
proxy_pass http://windows.abc.com;
}
#判断一下user-agent,如果是MSIE 5.01就把它丢到另外一个地方去就可以了,比如指向www.qq.com,看看能不能抗得住,哈哈
proxy_hide_header Cache-Control;
最后开回Cache-Control,访问一下页面
这下这个链接就缓存到前端squid了,应用服务器不会死机了
#########################################################
nginx中location模块的详细参数介绍
Nginx的Location可以有以下几个匹配:
1. = 严格匹配这个查询。如果找到,停止搜索。
2. ^~ 匹配路径的前缀,如果找到,停止搜索。
3. ~ 为区分大小写的正则匹配
4. ~* 为不区分大小写匹配
5.!~和!~*分别为区分大小写不匹配及不区分大小写不匹配
文件及目录匹配
* -f和!-f用来判断是否存在文件
* -d和!-d用来判断是否存在目录
* -e和!-e用来判断是否存在文件或目录
* -x和!-x用来判断文件是否可执行
一些可用的全局变量
$args
$content_length
$content_type
$document_root
$document_uri
$host
$http_user_agent
$http_cookie
$limit_rate
$request_body_file
$request_method
$remote_addr
$remote_port
$remote_user
$request_filename
$request_uri
$query_string
$scheme
$server_protocol
$server_addr
$server_name
$server_port
$uri
rewrite后面的flag可以是:
last
break
redirect
permanent
proxy_pass http://localhost:80;
proxy_set_header Host $host;
可以自动改变转发以后的域名信息
nginx根据http_user_agent防DDOS
首先查看访问日志,找出可疑访问 找到http_user_agent 的特征,然后再作过滤
"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; MyIE 3.01)Cache-Control: no-store, must-revalidate"
if ($http_user_agent ~ must-revalidate) {
return 503;
}
#这样就返回503错误
location = / {
include proxy.conf;
if ( $http_user_agent ~* "MSIE 5.01" ) {
proxy_pass http://www.qq.com;
#access_log /usr/local/nginx/logs/k.log main;
}
proxy_pass http://windows.abc.com;
}
#判断一下user-agent,如果是MSIE 5.01就把它丢到另外一个地方去就可以了,比如指向www.qq.com,看看能不能抗得住,哈哈
proxy_hide_header Cache-Control;
最后开回Cache-Control,访问一下页面
这下这个链接就缓存到前端squid了,应用服务器不会死机了
#########################################################
nginx中location模块的详细参数介绍
Nginx的Location可以有以下几个匹配:
1. = 严格匹配这个查询。如果找到,停止搜索。
2. ^~ 匹配路径的前缀,如果找到,停止搜索。
3. ~ 为区分大小写的正则匹配
4. ~* 为不区分大小写匹配
5.!~和!~*分别为区分大小写不匹配及不区分大小写不匹配
文件及目录匹配
* -f和!-f用来判断是否存在文件
* -d和!-d用来判断是否存在目录
* -e和!-e用来判断是否存在文件或目录
* -x和!-x用来判断文件是否可执行
一些可用的全局变量
$args
$content_length
$content_type
$document_root
$document_uri
$host
$http_user_agent
$http_cookie
$limit_rate
$request_body_file
$request_method
$remote_addr
$remote_port
$remote_user
$request_filename
$request_uri
$query_string
$scheme
$server_protocol
$server_addr
$server_name
$server_port
$uri
rewrite后面的flag可以是:
last
break
redirect
permanent
proxy_pass http://localhost:80;
proxy_set_header Host $host;
可以自动改变转发以后的域名信息
相关文章推荐
- nginx根据http_user_agent防DDOS
- nginx根据http_user_agent防DDOS
- nginx根据http_user_agent防DDOS
- nginx根据http_user_agent中包含的内容进行跳转
- Nginx http_user_agent 防御 ab 等
- Nginx根据User-Agent适配PC和手机
- Nginx http_user_agent 防御 ab 等
- nginx根据user_agent做访问控制
- 使用 Nginx 内置 $http_user_agent 来区分( 电脑 pc、手机 mobile、平板 pad )端的内容访问
- 利用nginx来屏蔽指定的user_agent的访问以及根据user_agent做跳转
- 技术文章 | nginx lua 小项目:根据 user_agent 显示不同的页面_附带和 php 性能的对比
- Nginx HTTP User_agent
- D10-Nginx-http_user_agent
- 微信浏览器的HTTP_USER_AGENT
- HTTP协议探索之userAgent
- Nginx配置——禁止指定user_agent
- PHP通过HTTP_USER_AGENT判断是否为手机移动终端的函数
- 根据 User Agent String 判断客户端平台及浏览器的 Java 程序
- php通过$_SERVER['HTTP_USER_AGENT']获取浏览器相关参数(转)
- php $_SERVER['HTTP_USER_AGENT']