nginx 根据userAgent屏蔽请求

2019-07-28  本文已影响0人  droxy

server {

listen 443;

server_name www.shangmayuan.com;

ssl on;

ssl_certificate  /data/nginx/cert.pem;

ssl_certificate_key  /data/nginx/cert.key;

ssl_session_timeout 5m;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!AEH:!FC4;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_prefer_server_ciphers on;

#禁止user-agent

if ($http_user_agent ~ "Cloudfind/1.0|http://www.google.com/bot.html|http://www.baidu.com/search/spider.htm" )

{

  return 403;

}

location / {

proxy_pass http://localhost:8080/;

proxy_redirect off;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $host:$server_port;

proxy_set_header X-Forwarded-Proto $scheme;

}

error_page  500 502 503 504  /404.html;

location = /404.html {

root  html;

}

上一篇下一篇

猜你喜欢

热点阅读