disable-robots.conf 731 B

1234567891011121314151617181920212223242526
  1. # Nginx UI Template Start
  2. name = "Disable Robots"
  3. author = "@0xJacky"
  4. description = { en = "Disable Robots", zh_CN = "禁止搜索引擎爬虫"}
  5. [variables.userAgents]
  6. type = "string"
  7. name = { en = "User Agents", zh_CN = "用户代理"}
  8. value = "Googlebot|Bingbot|Baiduspider|YandexBot|Slurp|DuckDuckBot|Sogou|360Spider|facebot|AhrefsBot|SEMrushBot"
  9. # Nginx UI Template End
  10. # Nginx UI Custom Start
  11. map $http_user_agent $is_bad_bot {
  12. default 0;
  13. ~*({{ .userAgents }}) 1;
  14. }
  15. # Nginx UI Custom End
  16. if ($is_bad_bot) {
  17. return 444;
  18. }
  19. location = /robots.txt {
  20. add_header Content-Type text/plain;
  21. add_header Cache-Control "no-store, no-cache, must-revalidate";
  22. return 200 "User-agent: *\nDisallow: /\n";
  23. }