Sub topic 10
Why robots.txt Is a Request, Not a Lock
Assume you know how web crawlers fetch pages, understand the HTTP User-Agent header, and can edit a website's root files. You should also be comfortable running curl and reading basic Python or server configuration.
What robots.txt can and cannot do
robots.txt is a text file at the root of a host, such as https://example.com/robots.txt. It uses the Robots Exclusion Protocol to publish instructions for automated clients. A crawler that follows the protocol checks the file before requesting a path.
This process is voluntary. The file does not authenticate a crawler, encrypt a page, or make a server reject a request. It also does not protect secrets. Do not place passwords, private URLs, or sensitive information in a disallowed directory and assume it is hidden.
A compliant crawler may avoid a path after reading Disallow. A malicious or careless client can ignore the file, use a different User-Agent value, or request the content before checking the file.
Common ways a crawler bypasses the file
A crawler can bypass a robots.txt policy in several ways:
- It can ignore the protocol completely.
- It can identify itself as an ordinary browser or as another crawler.
- It can use a misleading User-Agent string that contains no recognizable token.
- It can obtain the content from a cache, feed, mirror, API, or another site.
- It can follow links without honoring the site's published policy.
The User-Agent header is only a claim supplied by the client. It is useful for cooperative traffic classification, but it is not proof of identity.
Enforce a block at the server
When a crawler ignores robots.txt, reject its request at a reverse proxy, web server, CDN, or application gateway. For example, this complete minimal Nginx configuration returns HTTP 403 for several claimed crawler tokens:
events {}
http {
map $http_user_agent $block_ai_crawler {
default 0;
~*GPTBot 1;
~*ClaudeBot 1;
~*CCBot 1;
}
server {
listen 80;
server_name example.com;
if ($block_ai_crawler) {
return 403;
}
location / {
root /var/www/html;
try_files $uri $uri/ =404;
}
}
}This check reduces unwanted traffic from honest clients that send these tokens. It does not stop a client from changing its header. Also check whether your CDN or load balancer receives the request first. A rule on the origin server may never run if the edge layer serves the response from its cache.
For stronger verification, compare the source IP with the crawler operator's published IP ranges. Keep those ranges current. Reverse DNS alone is weak because a name can be changed or spoofed, and forward-confirmed reverse DNS still depends on the provider's domain policy. IP verification can also fail when traffic passes through proxies.
Monitor what actually happens
Review access logs for the claimed User-Agent, response status, request path, and source IP. A 403 response shows that your server rejected a request. It does not prove that the client is the crawler it claims to be. Compare repeated traffic with the operator's documented identity checks and IP ranges.
Monitoring also finds policy mistakes. If legitimate users receive 403 responses because their User-Agent contains a blocked token, narrow the rule or move enforcement to a verified edge policy.
Exercise
Why should a site use authentication instead of robots.txt to protect a private report?
Show answer
robots.txt only asks compliant crawlers not to fetch the report. Any client can ignore the request or discover the URL, while authentication requires the requester to prove access before the server returns the content.