> For the complete documentation index, see [llms.txt](https://notes.leetdev.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.leetdev.net/ubuntu/nginx-server-configuration/untitled-1.md).

# Robots.txt disallow all with nginx

If you’re managing an environment similar to a production and want to keep bots from indexing traffic, it’s customary to add a *robots.txt* file at the root of your website to [disallow all](http://www.robotstxt.org/faq/prevent.html). Instead of creating a two-line plain text file, you can do this with only nginx:

```
location = /robots.txt {
  add_header  Content-Type  text/plain;
  return 200 "User-agent: *\nDisallow: /\n";
}
```

Add this into your configuration management as determined by environment, or add it by hand, and no longer worry if Google might start broadcasting your dev site to the world.
