]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/recursordist/docs/http-api/index.rst
d63eced8c1c4d878d69e338686f18f9a5ed011f4
[thirdparty/pdns.git] / pdns / recursordist / docs / http-api / index.rst
1 Built-in Webserver and HTTP API
2 ===============================
3
4 The PowerDNS Recursor features a built-in built-in webserver that exposes a JSON/REST API.
5 This API allows for controlling several functions and reading statistics.
6
7 The following documents contain the information for the PowerDNS API:
8
9 .. toctree::
10 :maxdepth: 1
11
12 ../common/api/dataformat
13 ../common/api/server
14 zone
15 ../common/api/configsetting
16 ../common/api/statisticitem
17
18
19 Webserver
20 ---------
21
22 To launch the internal webserver, add a :ref:`setting-webserver` to the configuration file.
23 This will instruct PowerDNS to start a webserver on localhost at port 8081, without password protection.
24 By default the webserver listens on localhost, meaning only local users (on the same host) will be able to access the webserver. Since the default ACL before 4.1.0 allows access from everywhere if :ref:`setting-webserver-address` is set to a different value, we strongly advise the use of a password protection.
25 The webserver lists a lot of potentially sensitive information about the PowerDNS process, including frequent queries, frequently failing queries, lists of remote hosts sending queries, hosts sending corrupt queries etc.
26 The webserver does not allow remote management.
27 The following webserver related configuration items are available:
28
29 * :ref:`setting-webserver`: If set to anything but 'no', a webserver is launched.
30 * :ref:`setting-webserver-address`: Address to bind the webserver to. Defaults to 127.0.0.1, which implies that only the local computer is able to connect to the nameserver! To allow remote hosts to connect, change to 0.0.0.0 or the physical IP address of your nameserver.
31 * :ref:`setting-webserver-password`: If set, viewers will have to enter this plaintext password in order to gain access to the statistics.
32 * :ref:`setting-webserver-port`: Port to bind the webserver to.
33 * :ref:`setting-webserver-allow-from`: Netmasks that are allowed to connect to the webserver
34
35 Enabling the API
36 ----------------
37
38 To enable the API, the webserver and the HTTP API need to be enabled.
39 Add these lines to the ``recursor.conf``::
40
41 webserver=yes
42 webserver-port=8082
43 api-key=changeme
44
45 And restart ``pdns_recursor``, the following examples should start working::
46
47 curl -v -H 'X-API-Key: changeme' http://127.0.0.1:8082/api/v1/servers/localhost | jq .
48 curl -v -H 'X-API-Key: changeme' http://127.0.0.1:8082/api/v1/servers/localhost/zones | jq .
49
50 URL Endpoints
51 -------------
52
53 All API endpoints for the PowerDNS Recursor are documented here:
54
55 .. toctree::
56 :maxdepth: 1
57
58 ../common/api/endpoint-api
59 ../common/api/endpoint-servers
60 endpoint-servers-config
61 ../common/api/endpoint-statistics.rst
62 endpoint-zones
63 endpoint-trace
64 endpoint-cache
65 ../common/api/endpoint-logging.rst
66 endpoint-failure
67 endpoint-rpz-stats