Allowing selected verified crawlers while blocking all others: nginx rules, IP ranges, and login pages
A User-Agent name proves nothing. Verify a crawler with the operator's current IP ranges or forward-confirmed reverse DNS, combine identity checks carefully, and never use a crawler bypass for private account data.

User-Agent: Googlebot is just text supplied by the client. Before you create an exception for any crawler, verify the source address by a method that the crawler's operator documents.
Pick the verification method the operator supports
Google supports two methods: match the source address against its published CIDR files, or perform a reverse DNS lookup, require the documented Google hostname suffix, then resolve that hostname forward and confirm that the original address is among the results. Google publishes the exact procedure and separate lists for common crawlers, special crawlers, and user-triggered fetchers in Verify requests from Google crawlers and fetchers.
Bing documents forward-confirmed reverse DNS: the reverse name must end in search.msn.com, and the forward lookup must return the original address. See How to verify that Bingbot is Bingbot. Do not assume every operator publishes a stable CIDR feed. Use only its current official documentation.
Do not paste sample ranges into production
IP allocations change. Generate an nginx include from the operator's current feed, support both IPv4 and IPv6 fields, and fail closed if the download, JSON parse, or validation fails. Keep the old known-good include until the replacement has passed every check.
The final comment is deliberate: nginx -t cannot validate a temporary file that no loaded configuration includes. A production updater should build a test configuration that includes the candidate, validate it, preserve the previous file, swap atomically, validate the live configuration, and reload only on success.
Combine the IP check with the crawler name
An operator's network may run more than one service. If the exception is specifically for Googlebot, require both a verified Google common-crawler address and a Googlebot User-Agent token. The address check makes the name useful; the name alone is never proof.
Generate the geo include as CIDR-to-value lines such as 66.249.64.0/19 1;, not allow directives. Keep the address source and User-Agent token tied to the same documented crawler class.
Login pages: keep private data private
Google states that pages requiring a login are not crawled. Do not give a crawler credentials, copy session cookies into nginx, or bypass application authentication for account pages. Customer workspaces, invoices, saved files, and tenant data stay behind the same authentication and authorization checks for every caller.
If material should be indexed, the clean solution is a separate public URL that returns the same public content to people and crawlers. That avoids cloaking and makes the security boundary obvious. A temporary Basic Auth bypass is reasonable only for content already approved for public release, and only after strong crawler verification.
With satisfy any, either valid Basic Auth or a matching access-module allow rule is enough. Confirm that the included file ends in deny all;, test an allowed address and an ordinary address, and verify that the application does not add a second private-data route below the bypass. nginx documents the interaction in satisfy.
A safe rollout checklist
• Start with one crawler and one public path.
• Record the exact official source URL and generated-file time.
• Keep IPv4 and IPv6 in step.
• Fail closed: a refresh failure keeps the previous list.
• Run nginx -t, reload gracefully, then test from an ordinary address.
• Watch allowed and denied counts. Remove an exception that is not delivering useful crawls.
• Never make the exception wider than the public content it needs.
For controls that apply to unknown and abusive clients, continue with robots.txt versus real server and CDN enforcement. Our earlier 14-day crawler log study shows why copied crawler names should not be trusted.
Need a second pair of eyes on a reverse-proxy or application boundary?
Talk to Biz59