* :ref:`setting-webserver-password`: If set, viewers will have to enter this plaintext password in order to gain access to the statistics, in addition to entering the configured API key on the index page.
* :ref:`setting-webserver-port`: Port to bind the webserver to.
* :ref:`setting-webserver-allow-from`: Netmasks that are allowed to connect to the webserver
+* :ref:`setting-webserver-max-bodysize`: Maximum request/response body size in megabytes
Enabling the API
----------------
::arg().set("webserver-password","Password required for accessing the webserver")="";
::arg().set("webserver-allow-from","Webserver/API access is only allowed from these subnets")="127.0.0.1,::1";
::arg().set("webserver-loglevel", "Amount of logging in the webserver (none, normal, detailed)") = "normal";
+ ::arg().set("webserver-max-bodysize","Webserver/API maximum request/response body size in megabytes")="2";
::arg().setSwitch("do-ipv6-additional-processing", "Do AAAA additional processing")="yes";
::arg().setSwitch("query-logging","Hint backends that queries should be logged")="no";
.. note::
The webserver logs these line on the NOTICE level. The :ref:`settings-loglevel` seting must be 5 or higher for these lines to end up in the log.
+.. _setting-webserver-max-bodysize:
+
+``webserver-max-bodysize``
+--------------------------
+- Integer
+- Default: 2
+
+Maximum request/response body size in megabytes.
+
.. _setting-webserver-password:
``webserver-password``
HttpRequest req(logprefix);
HttpResponse resp;
+ resp.max_response_size=d_maxbodysize;
ComboAddress remote;
string reply;
try {
YaHTTP::AsyncRequestLoader yarl;
yarl.initialize(&req);
+ req.max_request_size=d_maxbodysize;
int timeout = 5;
client->setNonBlocking();
WebServer::WebServer(const string &listenaddress, int port) :
d_listenaddress(listenaddress),
d_port(port),
- d_server(nullptr)
+ d_server(nullptr),
+ d_maxbodysize(2*1024*1024)
{
}
d_webserverPassword = password;
}
+ void setMaxBodySize(ssize_t s) { // in megabytes
+ d_maxbodysize = s * 1024 * 1024;
+ }
+
void setACL(const NetmaskGroup &nmg) {
d_acl = nmg;
}
std::string d_webserverPassword;
bool d_registerWebHandlerCalled{false};
+ ssize_t d_maxbodysize; // in bytes
+
NetmaskGroup d_acl;
const string d_logprefix = "[webserver] ";
acl.toMasks(::arg()["webserver-allow-from"]);
d_ws->setACL(acl);
+ d_ws->setMaxBodySize(::arg().asNum("webserver-max-bodysize"));
+
d_ws->bind();
}
}