标签:Nginx负载均衡和防爬虫策略 nginx负载均衡设置 nginx设置 nginx
Nginx负载均衡和防爬虫策略
vim langba888.conf
upstream langba888 {
#每60s进行一次健康检测,检测2次失败,则进行剔除
server 192.168.137.52:888 max_fails=2 fail_timeout=60s;
server 192.168.137.48:888 max_fails=2 fail_timeout=60s;
}
server {
listen 9999;
#防止爬虫策略
if ($http_user_agent ~* "WordPress") {
return 502;
}
if ($http_user_agent ~* "spider") {
return 502;
}
location / {
proxy_pass http://langba888; #反向代理
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 403 /40x.html;
location = /40x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
标签:Nginx负载均衡和防爬虫策略 nginx负载均衡设置 nginx设置 nginx
原文地址:http://blog.51cto.com/8999a/2120015