2017-06-08 13:48:04 -06:00
|
|
|
# hosts
|
|
|
|
|
|
2017-07-24 08:24:53 -07:00
|
|
|
*hosts* enables serving zone data from a `/etc/hosts` style file.
|
2017-06-08 13:48:04 -06:00
|
|
|
|
2017-07-23 21:15:16 +01:00
|
|
|
The hosts middleware is useful for serving zones from a /etc/hosts file. It serves from a preloaded
|
2017-06-08 13:48:04 -06:00
|
|
|
file that exists on disk. It checks the file for changes and updates the zones accordingly. This
|
|
|
|
|
middleware only supports A, AAAA, and PTR records. The hosts middleware can be used with readily
|
|
|
|
|
available hosts files that block access to advertising servers.
|
|
|
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
|
|
|
|
|
~~~
|
2017-07-23 21:15:16 +01:00
|
|
|
hosts [FILE [ZONES...]] {
|
2017-06-08 13:48:04 -06:00
|
|
|
fallthrough
|
|
|
|
|
}
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
* **FILE** the hosts file to read and parse. If the path is relative the path from the *root*
|
|
|
|
|
directive will be prepended to it. Defaults to /etc/hosts if omitted
|
|
|
|
|
* **ZONES** zones it should be authoritative for. If empty, the zones from the configuration block
|
2017-07-23 21:15:16 +01:00
|
|
|
are used.
|
2017-06-08 13:48:04 -06:00
|
|
|
* `fallthrough` If zone matches and no record can be generated, pass request to the next middleware.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
2017-07-23 21:15:16 +01:00
|
|
|
Load `/etc/hosts` file.
|
2017-06-08 13:48:04 -06:00
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
hosts
|
|
|
|
|
~~~
|
|
|
|
|
|
2017-07-23 21:15:16 +01:00
|
|
|
Load `example.hosts` file in the current directory.
|
2017-06-08 13:48:04 -06:00
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
hosts example.hosts
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
Load example.hosts file and only serve example.org and example.net from it and fall through to the
|
2017-07-23 21:15:16 +01:00
|
|
|
next middleware if query doesn't match.
|
2017-06-08 13:48:04 -06:00
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
hosts example.hosts example.org example.net {
|
|
|
|
|
fallthrough
|
|
|
|
|
}
|
|
|
|
|
~~~
|