如何将 Nginx 服务器块中的 IP 地址/域列入黑名单
我正在尝试将一些正在访问我的网站的机器人列入黑名单。该机器人来自 paymentverificatiion.com
<<请注意“验证”上的两个“i”。我首先通过执行 nslookup paymentverificatiion.com
找到了 IP 地址,该命令返回:
Non-authoritative answer:
Name: paymentverificatiion.com
Address: 143.198.76.27
然后我尝试在每个位置块中放置 deny
语句,但这不起作用。然后我尝试将其放入服务器块中,但这不起作用:
upstream backend_server {
server backend:8000;
}
server {
listen 80;
deny 143.198.76.27;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location /api/ {
return 301 https://$host$request_uri;
}
location /admin/ {
return 301 https://$host$request_uri;
}
location /static/ {
return 301 https://$host$request_uri;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com *.example.com;
location /api/ {
proxy_pass http://backend_server$request_uri;
...omitted...
}
location /videos/ {
...omitted...
}
location /admin/ {
proxy_pass http://backend_server$request_uri;
...omitted...
}
location /static/ {
alias /backend/assets/;
}
location /media/ {
alias /backend/media/;
}
location / {
proxy_pass http://backend_server$request_uri;
...omitted...
}
}
如何将这些机器人列入黑名单?
I am trying to blacklist some bots that are hitting one of my sites. The bot comes from paymentverificatiion.com
<< notice two "i"s on "verification". I first found the IP address by doing nslookup paymentverificatiion.com
which returns:
Non-authoritative answer:
Name: paymentverificatiion.com
Address: 143.198.76.27
I then tried putting a deny
statement in each location block, but that did not work. I then tried putting it in the server block, but that does not work:
upstream backend_server {
server backend:8000;
}
server {
listen 80;
deny 143.198.76.27;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location /api/ {
return 301 https://$host$request_uri;
}
location /admin/ {
return 301 https://$host$request_uri;
}
location /static/ {
return 301 https://$host$request_uri;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com *.example.com;
location /api/ {
proxy_pass http://backend_server$request_uri;
...omitted...
}
location /videos/ {
...omitted...
}
location /admin/ {
proxy_pass http://backend_server$request_uri;
...omitted...
}
location /static/ {
alias /backend/assets/;
}
location /media/ {
alias /backend/media/;
}
location / {
proxy_pass http://backend_server$request_uri;
...omitted...
}
}
How can I blacklist these bots?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论