2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
|
|
|
|
2009-10-11 14:31:42 +00:00
|
|
|
#include "server.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "stream.h"
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
#include "configparser.h"
|
|
|
|
#include "configfile.h"
|
|
|
|
#include "proc_open.h"
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2008-04-29 11:03:41 +00:00
|
|
|
#include <limits.h>
|
2005-02-20 14:27:00 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
static int config_insert(server *srv) {
|
|
|
|
size_t i;
|
|
|
|
int ret = 0;
|
2005-08-08 08:22:06 +00:00
|
|
|
buffer *stat_cache_string;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
|
|
|
config_values_t cv[] = {
|
2015-11-07 12:51:11 +00:00
|
|
|
{ "server.bind", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 0 */
|
|
|
|
{ "server.errorlog", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 1 */
|
|
|
|
{ "server.errorfile-prefix", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
|
|
|
|
{ "server.chroot", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 3 */
|
|
|
|
{ "server.username", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 4 */
|
|
|
|
{ "server.groupname", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 5 */
|
|
|
|
{ "server.port", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 6 */
|
|
|
|
{ "server.tag", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
|
|
|
|
{ "server.use-ipv6", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
|
|
|
|
{ "server.modules", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_SERVER }, /* 9 */
|
|
|
|
|
|
|
|
{ "server.event-handler", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 10 */
|
|
|
|
{ "server.pid-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 11 */
|
|
|
|
{ "server.max-request-size", NULL, T_CONFIG_INT, T_CONFIG_SCOPE_SERVER }, /* 12 */
|
|
|
|
{ "server.max-worker", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 13 */
|
|
|
|
{ "server.document-root", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 14 */
|
|
|
|
{ "server.force-lowercase-filenames", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 15 */
|
|
|
|
{ "debug.log-condition-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 16 */
|
|
|
|
{ "server.max-keep-alive-requests", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 17 */
|
|
|
|
{ "server.name", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 18 */
|
|
|
|
{ "server.max-keep-alive-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 19 */
|
|
|
|
|
|
|
|
{ "server.max-read-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 20 */
|
|
|
|
{ "server.max-write-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 21 */
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
{ "server.error-handler", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 22 */
|
2015-11-07 12:51:11 +00:00
|
|
|
{ "server.max-fds", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 23 */
|
2006-09-07 11:00:02 +00:00
|
|
|
#ifdef HAVE_LSTAT
|
2015-11-07 12:51:11 +00:00
|
|
|
{ "server.follow-symlink", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 24 */
|
2006-09-07 11:00:02 +00:00
|
|
|
#else
|
|
|
|
{ "server.follow-symlink",
|
2015-11-07 12:51:11 +00:00
|
|
|
"Your system lacks lstat(). We can not differ symlinks from files."
|
|
|
|
"Please remove server.follow-symlinks from your config.",
|
|
|
|
T_CONFIG_UNSUPPORTED, T_CONFIG_SCOPE_UNSET },
|
2006-09-07 11:00:02 +00:00
|
|
|
#endif
|
2015-11-07 12:51:11 +00:00
|
|
|
{ "server.kbytes-per-second", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 25 */
|
|
|
|
{ "connection.kbytes-per-second", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 26 */
|
|
|
|
{ "mimetype.use-xattr", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 27 */
|
|
|
|
{ "mimetype.assign", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 28 */
|
|
|
|
{ "ssl.pemfile", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 29 */
|
|
|
|
|
|
|
|
{ "ssl.engine", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 30 */
|
|
|
|
{ "debug.log-file-not-found", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 31 */
|
|
|
|
{ "debug.log-request-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 32 */
|
|
|
|
{ "debug.log-response-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 33 */
|
|
|
|
{ "debug.log-request-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 34 */
|
|
|
|
{ "debug.log-ssl-noise", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 35 */
|
|
|
|
{ "server.protocol-http11", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 36 */
|
|
|
|
{ "debug.log-request-header-on-error", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 37 */
|
|
|
|
{ "debug.log-state-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 38 */
|
|
|
|
{ "ssl.ca-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 39 */
|
|
|
|
|
|
|
|
{ "server.errorlog-use-syslog", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 40 */
|
|
|
|
{ "server.range-requests", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 41 */
|
|
|
|
{ "server.stat-cache-engine", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 42 */
|
|
|
|
{ "server.max-connections", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 43 */
|
|
|
|
{ "server.network-backend", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 44 */
|
|
|
|
{ "server.upload-dirs", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_SERVER }, /* 45 */
|
|
|
|
{ "server.core-files", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 46 */
|
|
|
|
{ "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 47 */
|
|
|
|
{ "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 48 */
|
|
|
|
{ "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 49 */
|
|
|
|
|
|
|
|
{ "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 50 */
|
|
|
|
{ "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 51 */
|
|
|
|
{ "server.reject-expect-100-with-417", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 52 */
|
|
|
|
{ "debug.log-timeouts", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 53 */
|
|
|
|
{ "server.defer-accept", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 54 */
|
|
|
|
{ "server.breakagelog", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 55 */
|
|
|
|
{ "ssl.verifyclient.activate", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 56 */
|
|
|
|
{ "ssl.verifyclient.enforce", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 57 */
|
|
|
|
{ "ssl.verifyclient.depth", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 58 */
|
|
|
|
{ "ssl.verifyclient.username", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 59 */
|
|
|
|
|
|
|
|
{ "ssl.verifyclient.exportcert", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 60 */
|
|
|
|
{ "server.set-v6only", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 61 */
|
|
|
|
{ "ssl.use-sslv3", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 62 */
|
|
|
|
{ "ssl.dh-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 63 */
|
|
|
|
{ "ssl.ec-curve", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 64 */
|
|
|
|
{ "ssl.disable-client-renegotiation", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 65 */
|
|
|
|
{ "ssl.honor-cipher-order", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 66 */
|
|
|
|
{ "ssl.empty-fragments", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 67 */
|
2015-11-07 12:51:14 +00:00
|
|
|
{ "server.upload-temp-file-size", NULL, T_CONFIG_INT, T_CONFIG_SCOPE_SERVER }, /* 68 */
|
2016-03-26 13:49:43 +00:00
|
|
|
{ "mimetype.xattr-name", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 69 */
|
2016-03-30 20:17:17 +00:00
|
|
|
{ "server.listen-backlog", NULL, T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION }, /* 70 */
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
{ "server.error-handler-404", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 71 */
|
2015-11-07 12:51:11 +00:00
|
|
|
|
|
|
|
{ "server.host",
|
|
|
|
"use server.bind instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.docroot",
|
|
|
|
"use server.document-root instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.virtual-root",
|
|
|
|
"load mod_simple_vhost and use simple-vhost.server-root instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.virtual-default-host",
|
|
|
|
"load mod_simple_vhost and use simple-vhost.default-host instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.virtual-docroot",
|
|
|
|
"load mod_simple_vhost and use simple-vhost.document-root instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.userid",
|
|
|
|
"use server.username instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.groupid",
|
|
|
|
"use server.groupname instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.use-keep-alive",
|
|
|
|
"use server.max-keep-alive-requests = 0 instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
{ "server.force-lower-case-files",
|
|
|
|
"use server.force-lowercase-filenames instead",
|
|
|
|
T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
|
|
|
|
|
|
|
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
|
2005-02-20 14:27:00 +00:00
|
|
|
};
|
|
|
|
|
2015-11-07 12:51:11 +00:00
|
|
|
/* all T_CONFIG_SCOPE_SERVER options */
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[0].destination = srv->srvconf.bindhost;
|
2005-07-26 08:26:28 +00:00
|
|
|
cv[1].destination = srv->srvconf.errorlog_file;
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[3].destination = srv->srvconf.changeroot;
|
|
|
|
cv[4].destination = srv->srvconf.username;
|
|
|
|
cv[5].destination = srv->srvconf.groupname;
|
|
|
|
cv[6].destination = &(srv->srvconf.port);
|
|
|
|
cv[9].destination = srv->srvconf.modules;
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[10].destination = srv->srvconf.event_handler;
|
|
|
|
cv[11].destination = srv->srvconf.pid_file;
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[12].destination = &(srv->srvconf.max_request_size);
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[13].destination = &(srv->srvconf.max_worker);
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[23].destination = &(srv->srvconf.max_fds);
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[37].destination = &(srv->srvconf.log_request_header_on_error);
|
|
|
|
cv[38].destination = &(srv->srvconf.log_state_handling);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[40].destination = &(srv->srvconf.errorlog_use_syslog);
|
2005-08-08 08:22:06 +00:00
|
|
|
stat_cache_string = buffer_init();
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[42].destination = stat_cache_string;
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[43].destination = &(srv->srvconf.max_conns);
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[44].destination = srv->srvconf.network_backend;
|
|
|
|
cv[45].destination = srv->srvconf.upload_tempdirs;
|
|
|
|
cv[46].destination = &(srv->srvconf.enable_cores);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2009-02-04 15:16:29 +00:00
|
|
|
cv[52].destination = &(srv->srvconf.reject_expect_100_with_417);
|
2009-06-21 17:25:39 +00:00
|
|
|
cv[55].destination = srv->srvconf.breakagelog_file;
|
|
|
|
|
2015-11-07 12:51:14 +00:00
|
|
|
cv[68].destination = &(srv->srvconf.upload_temp_file_size);
|
2016-03-26 13:49:43 +00:00
|
|
|
cv[69].destination = srv->srvconf.xattr_name;
|
2015-11-07 12:51:14 +00:00
|
|
|
|
2005-06-29 15:31:54 +00:00
|
|
|
srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2014-02-16 13:08:20 +00:00
|
|
|
force_assert(srv->config_storage);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
for (i = 0; i < srv->config_context->used; i++) {
|
2015-11-07 12:51:11 +00:00
|
|
|
data_config const* config = (data_config const*)srv->config_context->data[i];
|
2005-02-20 14:27:00 +00:00
|
|
|
specific_config *s;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
s = calloc(1, sizeof(specific_config));
|
2014-02-16 13:08:20 +00:00
|
|
|
force_assert(s);
|
2005-02-20 14:27:00 +00:00
|
|
|
s->document_root = buffer_init();
|
|
|
|
s->mimetypes = array_init();
|
|
|
|
s->server_name = buffer_init();
|
|
|
|
s->ssl_pemfile = buffer_init();
|
2005-02-28 00:00:55 +00:00
|
|
|
s->ssl_ca_file = buffer_init();
|
2005-02-20 14:27:00 +00:00
|
|
|
s->error_handler = buffer_init();
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
s->error_handler_404 = buffer_init();
|
2005-02-20 14:27:00 +00:00
|
|
|
s->server_tag = buffer_init();
|
2006-09-07 10:19:29 +00:00
|
|
|
s->ssl_cipher_list = buffer_init();
|
2011-03-13 18:00:09 +00:00
|
|
|
s->ssl_dh_file = buffer_init();
|
|
|
|
s->ssl_ec_curve = buffer_init();
|
2005-07-15 13:26:16 +00:00
|
|
|
s->errorfile_prefix = buffer_init();
|
2005-09-26 08:49:13 +00:00
|
|
|
s->max_keep_alive_requests = 16;
|
|
|
|
s->max_keep_alive_idle = 5;
|
2005-02-20 14:27:00 +00:00
|
|
|
s->max_read_idle = 60;
|
|
|
|
s->max_write_idle = 360;
|
|
|
|
s->use_xattr = 0;
|
2013-07-31 20:23:21 +00:00
|
|
|
s->ssl_enabled = 0;
|
2011-11-30 19:59:24 +00:00
|
|
|
s->ssl_honor_cipher_order = 1;
|
2013-08-30 13:14:50 +00:00
|
|
|
s->ssl_empty_fragments = 0;
|
2009-02-03 22:10:25 +00:00
|
|
|
s->ssl_use_sslv2 = 0;
|
2014-10-16 17:52:14 +00:00
|
|
|
s->ssl_use_sslv3 = 0;
|
2005-02-20 14:27:00 +00:00
|
|
|
s->use_ipv6 = 0;
|
2010-08-07 13:16:16 +00:00
|
|
|
s->set_v6only = 1;
|
2009-04-26 17:59:55 +00:00
|
|
|
s->defer_accept = 0;
|
2006-09-07 11:00:02 +00:00
|
|
|
#ifdef HAVE_LSTAT
|
2005-02-20 14:27:00 +00:00
|
|
|
s->follow_symlink = 1;
|
2006-09-07 11:00:02 +00:00
|
|
|
#endif
|
2005-02-20 14:27:00 +00:00
|
|
|
s->kbytes_per_second = 0;
|
|
|
|
s->allow_http11 = 1;
|
2007-06-15 15:51:16 +00:00
|
|
|
s->etag_use_inode = 1;
|
|
|
|
s->etag_use_mtime = 1;
|
|
|
|
s->etag_use_size = 1;
|
2005-07-28 21:05:16 +00:00
|
|
|
s->range_requests = 1;
|
2010-08-07 11:56:09 +00:00
|
|
|
s->force_lowercase_filenames = (i == 0) ? 2 : 0; /* we wan't to detect later if user changed this for global section */
|
2005-02-20 14:27:00 +00:00
|
|
|
s->global_kbytes_per_second = 0;
|
|
|
|
s->global_bytes_per_second_cnt = 0;
|
|
|
|
s->global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
|
2009-10-14 18:19:19 +00:00
|
|
|
s->ssl_verifyclient = 0;
|
|
|
|
s->ssl_verifyclient_enforce = 1;
|
|
|
|
s->ssl_verifyclient_username = buffer_init();
|
|
|
|
s->ssl_verifyclient_depth = 9;
|
2009-11-05 21:46:48 +00:00
|
|
|
s->ssl_verifyclient_export_cert = 0;
|
2011-11-30 18:40:08 +00:00
|
|
|
s->ssl_disable_client_renegotiation = 1;
|
2016-03-30 20:17:17 +00:00
|
|
|
s->listen_backlog = (0 == i ? 1024 : srv->config_storage[0]->listen_backlog);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2015-11-07 12:51:11 +00:00
|
|
|
/* all T_CONFIG_SCOPE_CONNECTION options */
|
2005-07-15 13:26:16 +00:00
|
|
|
cv[2].destination = s->errorfile_prefix;
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[7].destination = s->server_tag;
|
|
|
|
cv[8].destination = &(s->use_ipv6);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[14].destination = s->document_root;
|
2006-01-11 23:05:06 +00:00
|
|
|
cv[15].destination = &(s->force_lowercase_filenames);
|
2005-08-15 09:55:23 +00:00
|
|
|
cv[16].destination = &(s->log_condition_handling);
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[17].destination = &(s->max_keep_alive_requests);
|
|
|
|
cv[18].destination = s->server_name;
|
|
|
|
cv[19].destination = &(s->max_keep_alive_idle);
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[20].destination = &(s->max_read_idle);
|
|
|
|
cv[21].destination = &(s->max_write_idle);
|
|
|
|
cv[22].destination = s->error_handler;
|
2006-09-07 11:00:02 +00:00
|
|
|
#ifdef HAVE_LSTAT
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[24].destination = &(s->follow_symlink);
|
2006-09-07 11:00:02 +00:00
|
|
|
#endif
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[25].destination = &(s->global_kbytes_per_second);
|
|
|
|
cv[26].destination = &(s->kbytes_per_second);
|
|
|
|
cv[27].destination = &(s->use_xattr);
|
|
|
|
cv[28].destination = s->mimetypes;
|
|
|
|
cv[29].destination = s->ssl_pemfile;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[30].destination = &(s->ssl_enabled);
|
2005-02-20 14:27:00 +00:00
|
|
|
cv[31].destination = &(s->log_file_not_found);
|
|
|
|
cv[32].destination = &(s->log_request_handling);
|
|
|
|
cv[33].destination = &(s->log_response_header);
|
|
|
|
cv[34].destination = &(s->log_request_header);
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[35].destination = &(s->log_ssl_noise);
|
|
|
|
cv[36].destination = &(s->allow_http11);
|
|
|
|
cv[39].destination = s->ssl_ca_file;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[41].destination = &(s->range_requests);
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[47].destination = s->ssl_cipher_list;
|
|
|
|
cv[48].destination = &(s->ssl_use_sslv2);
|
|
|
|
cv[49].destination = &(s->etag_use_inode);
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2008-08-19 17:40:42 +00:00
|
|
|
cv[50].destination = &(s->etag_use_mtime);
|
|
|
|
cv[51].destination = &(s->etag_use_size);
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[53].destination = &(s->log_timeouts);
|
|
|
|
cv[54].destination = &(s->defer_accept);
|
2009-10-14 18:19:19 +00:00
|
|
|
cv[56].destination = &(s->ssl_verifyclient);
|
|
|
|
cv[57].destination = &(s->ssl_verifyclient_enforce);
|
|
|
|
cv[58].destination = &(s->ssl_verifyclient_depth);
|
|
|
|
cv[59].destination = s->ssl_verifyclient_username;
|
2015-11-07 12:51:11 +00:00
|
|
|
|
2009-11-05 21:46:48 +00:00
|
|
|
cv[60].destination = &(s->ssl_verifyclient_export_cert);
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[61].destination = &(s->set_v6only);
|
|
|
|
cv[62].destination = &(s->ssl_use_sslv3);
|
|
|
|
cv[63].destination = s->ssl_dh_file;
|
|
|
|
cv[64].destination = s->ssl_ec_curve;
|
2011-11-30 18:40:08 +00:00
|
|
|
cv[65].destination = &(s->ssl_disable_client_renegotiation);
|
2015-11-07 12:51:11 +00:00
|
|
|
cv[66].destination = &(s->ssl_honor_cipher_order);
|
|
|
|
cv[67].destination = &(s->ssl_empty_fragments);
|
2016-03-30 20:17:17 +00:00
|
|
|
cv[70].destination = &(s->listen_backlog);
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
cv[71].destination = s->error_handler_404;
|
2009-10-14 18:19:19 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
srv->config_storage[i] = s;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2015-11-07 12:51:11 +00:00
|
|
|
if (0 != (ret = config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION))) {
|
2005-02-20 14:27:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2015-02-08 12:37:10 +00:00
|
|
|
if (buffer_string_is_empty(stat_cache_string)) {
|
2005-11-11 12:44:34 +00:00
|
|
|
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_SIMPLE;
|
2005-08-08 08:22:06 +00:00
|
|
|
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("simple"))) {
|
|
|
|
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_SIMPLE;
|
2007-02-19 13:55:07 +00:00
|
|
|
#ifdef HAVE_FAM_H
|
2005-08-08 08:22:06 +00:00
|
|
|
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("fam"))) {
|
|
|
|
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_FAM;
|
2007-02-19 13:55:07 +00:00
|
|
|
#endif
|
2005-08-08 08:22:06 +00:00
|
|
|
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("disable"))) {
|
|
|
|
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_NONE;
|
|
|
|
} else {
|
2006-10-04 13:26:23 +00:00
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sb",
|
2007-02-19 13:55:07 +00:00
|
|
|
"server.stat-cache-engine can be one of \"disable\", \"simple\","
|
|
|
|
#ifdef HAVE_FAM_H
|
|
|
|
" \"fam\","
|
|
|
|
#endif
|
|
|
|
" but not:", stat_cache_string);
|
2005-08-08 08:22:06 +00:00
|
|
|
ret = HANDLER_ERROR;
|
|
|
|
}
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-08-08 08:22:06 +00:00
|
|
|
buffer_free(stat_cache_string);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
return ret;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define PATCH(x) con->conf.x = s->x
|
|
|
|
int config_setup_connection(server *srv, connection *con) {
|
|
|
|
specific_config *s = srv->config_storage[0];
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(allow_http11);
|
|
|
|
PATCH(mimetypes);
|
|
|
|
PATCH(document_root);
|
|
|
|
PATCH(max_keep_alive_requests);
|
|
|
|
PATCH(max_keep_alive_idle);
|
|
|
|
PATCH(max_read_idle);
|
|
|
|
PATCH(max_write_idle);
|
|
|
|
PATCH(use_xattr);
|
|
|
|
PATCH(error_handler);
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
PATCH(error_handler_404);
|
2005-07-15 13:26:16 +00:00
|
|
|
PATCH(errorfile_prefix);
|
2006-09-07 11:00:02 +00:00
|
|
|
#ifdef HAVE_LSTAT
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(follow_symlink);
|
2006-09-07 11:00:02 +00:00
|
|
|
#endif
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(server_tag);
|
|
|
|
PATCH(kbytes_per_second);
|
|
|
|
PATCH(global_kbytes_per_second);
|
|
|
|
PATCH(global_bytes_per_second_cnt);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
con->conf.global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
|
2015-02-08 12:37:10 +00:00
|
|
|
buffer_copy_buffer(con->server_name, s->server_name);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(log_request_header);
|
|
|
|
PATCH(log_response_header);
|
|
|
|
PATCH(log_request_handling);
|
2005-08-08 13:48:33 +00:00
|
|
|
PATCH(log_condition_handling);
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(log_file_not_found);
|
2008-08-19 17:40:42 +00:00
|
|
|
PATCH(log_ssl_noise);
|
2009-07-01 16:04:17 +00:00
|
|
|
PATCH(log_timeouts);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-07-28 21:05:16 +00:00
|
|
|
PATCH(range_requests);
|
2006-01-11 23:05:06 +00:00
|
|
|
PATCH(force_lowercase_filenames);
|
2016-03-30 20:17:17 +00:00
|
|
|
/*PATCH(listen_backlog);*//*(not necessary; used only at startup)*/
|
2013-07-31 20:23:21 +00:00
|
|
|
PATCH(ssl_enabled);
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-08-18 09:25:59 +00:00
|
|
|
PATCH(ssl_pemfile);
|
2009-10-14 19:05:00 +00:00
|
|
|
#ifdef USE_OPENSSL
|
2013-11-05 15:29:07 +00:00
|
|
|
PATCH(ssl_pemfile_x509);
|
|
|
|
PATCH(ssl_pemfile_pkey);
|
2009-10-14 19:05:00 +00:00
|
|
|
#endif
|
2005-08-18 09:25:59 +00:00
|
|
|
PATCH(ssl_ca_file);
|
2013-11-05 15:29:07 +00:00
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
PATCH(ssl_ca_file_cert_names);
|
|
|
|
#endif
|
2006-09-07 10:19:29 +00:00
|
|
|
PATCH(ssl_cipher_list);
|
2011-03-13 18:00:09 +00:00
|
|
|
PATCH(ssl_dh_file);
|
|
|
|
PATCH(ssl_ec_curve);
|
2011-11-30 19:59:24 +00:00
|
|
|
PATCH(ssl_honor_cipher_order);
|
2013-08-30 13:14:50 +00:00
|
|
|
PATCH(ssl_empty_fragments);
|
2006-09-07 10:19:29 +00:00
|
|
|
PATCH(ssl_use_sslv2);
|
2011-03-13 18:00:09 +00:00
|
|
|
PATCH(ssl_use_sslv3);
|
2007-06-15 15:51:16 +00:00
|
|
|
PATCH(etag_use_inode);
|
|
|
|
PATCH(etag_use_mtime);
|
|
|
|
PATCH(etag_use_size);
|
2009-10-14 18:19:19 +00:00
|
|
|
|
|
|
|
PATCH(ssl_verifyclient);
|
|
|
|
PATCH(ssl_verifyclient_enforce);
|
|
|
|
PATCH(ssl_verifyclient_depth);
|
|
|
|
PATCH(ssl_verifyclient_username);
|
2009-11-05 21:46:48 +00:00
|
|
|
PATCH(ssl_verifyclient_export_cert);
|
2011-11-30 18:40:08 +00:00
|
|
|
PATCH(ssl_disable_client_renegotiation);
|
2009-10-14 18:19:19 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-21 18:32:17 +00:00
|
|
|
int config_patch_connection(server *srv, connection *con) {
|
2005-02-20 14:27:00 +00:00
|
|
|
size_t i, j;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
/* skip the first, the global context */
|
|
|
|
for (i = 1; i < srv->config_context->used; i++) {
|
|
|
|
data_config *dc = (data_config *)srv->config_context->data[i];
|
|
|
|
specific_config *s = srv->config_storage[i];
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
/* condition didn't match */
|
|
|
|
if (!config_check_cond(srv, con, dc)) continue;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
/* merge config */
|
|
|
|
for (j = 0; j < dc->value->used; j++) {
|
|
|
|
data_unset *du = dc->value->data[j];
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.document-root"))) {
|
|
|
|
PATCH(document_root);
|
2005-07-28 21:05:16 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.range-requests"))) {
|
|
|
|
PATCH(range_requests);
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.error-handler"))) {
|
2005-02-20 14:27:00 +00:00
|
|
|
PATCH(error_handler);
|
[core] server.error-handler new directive for error pages (fixes #2702)
server.error-handler preserves HTTP status error code when error page
is static, and allows dynamic handlers to change HTTP status code
when error page is provided by dynamic handler. server.error-handler
intercepts all HTTP status codes >= 400 except when the content is
generated by a dynamic handler (cgi, ssi, fastcgi, scgi, proxy, lua).
The request method is unconditionally changed to GET for the request
to service the error handler, and the original request method is
later restored (for logging purposes). request body from the
original request, if present, is discarded.
server.error-handler is somewhat similar to server.error-handler-404,
but server.error-handler-404 is now deprecated, intercepts only 404
and 403 HTTP status codes, and returns 200 OK for static error pages,
a source of confusion for some admins. On the other hand, the new
server.error-handler, when set, will intercept all HTTP status error
codes >= 400. server.error-handler takes precedence over
server.error-handler-404 when both are set.
NOTE: a major difference between server.error-handler and the
now-deprecated server.error-handler-404 is that the values of the
non-standard CGI environment variables REQUEST_URI and REDIRECT_URI
have been swapped. Since REDIRECT_STATUS is the original HTTP
status code, REDIRECT_URI is now the original request, and REQUEST_URI
is the current request (e.g. the URI/URL to the error handler).
The prior behavior -- which reversed REQUEST_URI and REDIRECT_URI values
from those described above -- is preserved for server.error-handler-404.
Additionally, REDIRECT_STATUS is now available to mod_magnet, which
continues to have access to request.uri and request.orig_uri.
See further discussion at https://redmine.lighttpd.net/issues/2702
and https://redmine.lighttpd.net/issues/1828
github: closes #36
2016-03-01 05:57:48 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.error-handler-404"))) {
|
|
|
|
PATCH(error_handler_404);
|
2005-07-15 13:44:54 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.errorfile-prefix"))) {
|
2005-07-15 13:26:16 +00:00
|
|
|
PATCH(errorfile_prefix);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("mimetype.assign"))) {
|
|
|
|
PATCH(mimetypes);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.max-keep-alive-requests"))) {
|
|
|
|
PATCH(max_keep_alive_requests);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.max-keep-alive-idle"))) {
|
|
|
|
PATCH(max_keep_alive_idle);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.max-write-idle"))) {
|
|
|
|
PATCH(max_write_idle);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.max-read-idle"))) {
|
|
|
|
PATCH(max_read_idle);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("mimetype.use-xattr"))) {
|
|
|
|
PATCH(use_xattr);
|
2007-06-15 15:51:16 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-inode"))) {
|
|
|
|
PATCH(etag_use_inode);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-mtime"))) {
|
|
|
|
PATCH(etag_use_mtime);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-size"))) {
|
|
|
|
PATCH(etag_use_size);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.pemfile"))) {
|
|
|
|
PATCH(ssl_pemfile);
|
2009-10-14 19:05:00 +00:00
|
|
|
#ifdef USE_OPENSSL
|
2013-11-05 15:29:07 +00:00
|
|
|
PATCH(ssl_pemfile_x509);
|
|
|
|
PATCH(ssl_pemfile_pkey);
|
2009-10-14 19:05:00 +00:00
|
|
|
#endif
|
2005-02-28 00:00:55 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.ca-file"))) {
|
|
|
|
PATCH(ssl_ca_file);
|
2013-11-05 15:29:07 +00:00
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
PATCH(ssl_ca_file_cert_names);
|
|
|
|
#endif
|
2011-11-30 19:59:24 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.honor-cipher-order"))) {
|
|
|
|
PATCH(ssl_honor_cipher_order);
|
2013-08-30 13:14:50 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.empty-fragments"))) {
|
|
|
|
PATCH(ssl_empty_fragments);
|
2006-09-07 10:19:29 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.use-sslv2"))) {
|
|
|
|
PATCH(ssl_use_sslv2);
|
2011-03-13 18:00:09 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.use-sslv3"))) {
|
|
|
|
PATCH(ssl_use_sslv3);
|
2006-09-07 10:19:29 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.cipher-list"))) {
|
|
|
|
PATCH(ssl_cipher_list);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.engine"))) {
|
2013-07-31 20:23:21 +00:00
|
|
|
PATCH(ssl_enabled);
|
2011-03-13 18:00:09 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.dh-file"))) {
|
|
|
|
PATCH(ssl_dh_file);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.ec-curve"))) {
|
|
|
|
PATCH(ssl_ec_curve);
|
2006-09-07 11:00:02 +00:00
|
|
|
#ifdef HAVE_LSTAT
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.follow-symlink"))) {
|
|
|
|
PATCH(follow_symlink);
|
2006-09-07 11:00:02 +00:00
|
|
|
#endif
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.name"))) {
|
2015-02-08 12:37:10 +00:00
|
|
|
buffer_copy_buffer(con->server_name, s->server_name);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.tag"))) {
|
|
|
|
PATCH(server_tag);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("connection.kbytes-per-second"))) {
|
|
|
|
PATCH(kbytes_per_second);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-request-handling"))) {
|
|
|
|
PATCH(log_request_handling);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-request-header"))) {
|
|
|
|
PATCH(log_request_header);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-response-header"))) {
|
|
|
|
PATCH(log_response_header);
|
2005-08-08 13:48:33 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-condition-handling"))) {
|
|
|
|
PATCH(log_condition_handling);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-file-not-found"))) {
|
|
|
|
PATCH(log_file_not_found);
|
2008-08-19 17:40:42 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-ssl-noise"))) {
|
|
|
|
PATCH(log_ssl_noise);
|
2009-02-05 21:54:47 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-timeouts"))) {
|
|
|
|
PATCH(log_timeouts);
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.protocol-http11"))) {
|
|
|
|
PATCH(allow_http11);
|
2006-10-04 13:26:23 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.force-lowercase-filenames"))) {
|
2006-01-11 23:05:06 +00:00
|
|
|
PATCH(force_lowercase_filenames);
|
2016-03-30 20:17:17 +00:00
|
|
|
#if 0 /*(not necessary; used only at startup)*/
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.listen-backlog"))) {
|
|
|
|
PATCH(listen_backlog);
|
|
|
|
#endif
|
2005-02-20 14:27:00 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.kbytes-per-second"))) {
|
|
|
|
PATCH(global_kbytes_per_second);
|
|
|
|
PATCH(global_bytes_per_second_cnt);
|
|
|
|
con->conf.global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
|
2009-10-14 18:19:19 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.verifyclient.activate"))) {
|
|
|
|
PATCH(ssl_verifyclient);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.verifyclient.enforce"))) {
|
|
|
|
PATCH(ssl_verifyclient_enforce);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.verifyclient.depth"))) {
|
|
|
|
PATCH(ssl_verifyclient_depth);
|
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.verifyclient.username"))) {
|
|
|
|
PATCH(ssl_verifyclient_username);
|
2009-11-05 21:46:48 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.verifyclient.exportcert"))) {
|
|
|
|
PATCH(ssl_verifyclient_export_cert);
|
2011-11-30 18:40:08 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.disable-client-renegotiation"))) {
|
|
|
|
PATCH(ssl_disable_client_renegotiation);
|
2005-02-20 14:27:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2007-07-03 18:47:00 +00:00
|
|
|
con->etag_flags = (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) |
|
|
|
|
(con->conf.etag_use_inode ? ETAG_USE_INODE : 0) |
|
|
|
|
(con->conf.etag_use_size ? ETAG_USE_SIZE : 0);
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#undef PATCH
|
2005-08-09 06:42:33 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
typedef struct {
|
|
|
|
int foo;
|
|
|
|
int bar;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-08-09 06:42:33 +00:00
|
|
|
const buffer *source;
|
2005-08-08 14:40:47 +00:00
|
|
|
const char *input;
|
2005-02-20 14:27:00 +00:00
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
int line_pos;
|
|
|
|
int line;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
int in_key;
|
|
|
|
int in_brace;
|
|
|
|
int in_cond;
|
|
|
|
} tokenizer_t;
|
|
|
|
|
2005-08-09 06:42:33 +00:00
|
|
|
#if 0
|
2005-08-08 14:40:47 +00:00
|
|
|
static int tokenizer_open(server *srv, tokenizer_t *t, buffer *basedir, const char *fn) {
|
2015-02-08 12:37:10 +00:00
|
|
|
if (buffer_string_is_empty(basedir) ||
|
2008-05-15 01:24:00 +00:00
|
|
|
(fn[0] == '/' || fn[0] == '\\') ||
|
2005-08-08 14:40:47 +00:00
|
|
|
(fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {
|
|
|
|
t->file = buffer_init_string(fn);
|
|
|
|
} else {
|
|
|
|
t->file = buffer_init_buffer(basedir);
|
|
|
|
buffer_append_string(t->file, fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 != stream_open(&(t->s), t->file)) {
|
2006-10-04 13:26:23 +00:00
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sbss",
|
2005-08-08 14:40:47 +00:00
|
|
|
"opening configfile ", t->file, "failed:", strerror(errno));
|
|
|
|
buffer_free(t->file);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
t->input = t->s.start;
|
|
|
|
t->offset = 0;
|
|
|
|
t->size = t->s.size;
|
|
|
|
t->line = 1;
|
|
|
|
t->line_pos = 1;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-08-08 14:40:47 +00:00
|
|
|
t->in_key = 1;
|
|
|
|
t->in_brace = 0;
|
|
|
|
t->in_cond = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tokenizer_close(server *srv, tokenizer_t *t) {
|
|
|
|
UNUSED(srv);
|
|
|
|
|
|
|
|
buffer_free(t->file);
|
|
|
|
return stream_close(&(t->s));
|
|
|
|
}
|
2005-08-09 06:42:33 +00:00
|
|
|
#endif
|
2005-08-08 13:48:33 +00:00
|
|
|
static int config_skip_newline(tokenizer_t *t) {
|
|
|
|
int skipped = 1;
|
2014-02-16 13:08:20 +00:00
|
|
|
force_assert(t->input[t->offset] == '\r' || t->input[t->offset] == '\n');
|
2005-08-08 13:48:33 +00:00
|
|
|
if (t->input[t->offset] == '\r' && t->input[t->offset + 1] == '\n') {
|
|
|
|
skipped ++;
|
|
|
|
t->offset ++;
|
|
|
|
}
|
|
|
|
t->offset ++;
|
|
|
|
return skipped;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_skip_comment(tokenizer_t *t) {
|
|
|
|
int i;
|
2014-02-16 13:08:20 +00:00
|
|
|
force_assert(t->input[t->offset] == '#');
|
2006-10-04 13:26:23 +00:00
|
|
|
for (i = 1; t->input[t->offset + i] &&
|
2005-08-08 13:48:33 +00:00
|
|
|
(t->input[t->offset + i] != '\n' && t->input[t->offset + i] != '\r');
|
|
|
|
i++);
|
|
|
|
t->offset += i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *token) {
|
|
|
|
int tid = 0;
|
|
|
|
size_t i;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
for (tid = 0; tid == 0 && t->offset < t->size && t->input[t->offset] ; ) {
|
|
|
|
char c = t->input[t->offset];
|
2005-08-08 14:40:47 +00:00
|
|
|
const char *start = NULL;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
switch (c) {
|
2006-10-04 13:26:23 +00:00
|
|
|
case '=':
|
2005-02-20 14:27:00 +00:00
|
|
|
if (t->in_brace) {
|
|
|
|
if (t->input[t->offset + 1] == '>') {
|
|
|
|
t->offset += 2;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2008-07-30 19:38:32 +00:00
|
|
|
buffer_copy_string_len(token, CONST_STR_LEN("=>"));
|
2006-10-04 13:26:23 +00:00 |