Commit Graph

2291 Commits (b2e2d42c8385c7485167baf7014492d8e4d724d0)

Author SHA1 Message Date
Glenn Strauss b2e2d42c83 [mod_proxy] support Forwarded HTTP Extension (fixes #2703)
To enable "Forwarded", must enable which params to include.
The recommended set is "for" and "proto" unless other params
are required and proper security precautions have been taken.
proxy.forwarded = ( "for" => 1,
                    "proto" => 1,
                    #"host" => 1,
                    #"by" => 1,
                    #"remote_user" => 1,
                  )

See https://tools.ietf.org/html/rfc7239 for info about "Forwarded"

x-ref:
  "Forwarded HTTP Extension"
  https://tools.ietf.org/html/rfc7239
  "Forward authenticated user to proxied requests"
  https://redmine.lighttpd.net/issues/2703
2017-04-06 00:22:42 -04:00
Glenn Strauss 371e1bf723 [mod_extforward] support Forwarded HTTP Extension (#2703)
enable with, e.g.:
extforward.headers = ( "Forwarded" )
or
extforward.headers = ( "Forwarded", "X-Forwarded-For" )
or
extforward.headers = ( "Forwarded", "X-Forwarded-For", "Forwarded-For" )

The default remains:
extforward.headers = ( "X-Forwarded-For", "Forwarded-For" )

Support for "Forwarded" is not enabled by default since intermediate
proxies might not be aware of Forwarded, and might therefore pass
spoofed Forwarded header received from client.

extforward.params = ( # overwrite "Host" with Forwarded value
                      #"host" => 1
                      # set REMOTE_USER with Forwarded value
                      #"remote_user" => 1
                    )
Note: be cautious configuring trusted proxies if enabling these options
since Forwarded header may be spoofed and passed along indescriminantly
by proxies which do not handle Forwarded.

To remove "Forwarded" from incoming requests, do not enable these
options and instead use mod_setenv to clear the request header:
  setenv.set-request-header = ( "Forwarded" => "" )

Other proxy-related headers which admin might evaluate to keep or clear:
  setenv.set-request-header = ( "X-Forwarded-For" => "",
                                "X-Forwarded-By" => "",
                                "X-Forwarded-Server" => "",
                                "X-Origin-IP" => "",
                                "Via" => "",
                                #...
                              )

x-ref:
  "Forwarded HTTP Extension"
  https://tools.ietf.org/html/rfc7239
  "Forward authenticated user to proxied requests"
  https://redmine.lighttpd.net/issues/2703
2017-04-06 00:22:41 -04:00
Glenn Strauss 36adf0d9a6 [mod_extforward] rearrange code; prep Forwarded 2017-04-06 00:20:28 -04:00
Glenn Strauss 3070972335 [mod_extforward] upd scheme after ipstr validated 2017-04-01 19:20:09 -04:00
Glenn Strauss e7ee5dbf78 [mod_extforward] consolidate ipstr_to_sockaddr() 2017-04-01 19:20:09 -04:00
Glenn Strauss c3c78599dd [mod_extforward] simplify header search 2017-04-01 19:20:09 -04:00
Glenn Strauss 1104afc49b [core] export http_request_host_policy() for reuse 2017-04-01 19:20:09 -04:00
Glenn Strauss 162e754d0d [core] report file path when mkstemp() fails (fixes #2802)
x-ref:
  "Could the error-log be improved a tiny bit in regards to "Permission denied" errors"
  https://redmine.lighttpd.net/issues/2802
2017-03-28 02:17:33 -04:00
Glenn Strauss 8cf6e908d3 [core] include <netdb.h> where needed
include <netdb.h> in files which use getaddrinfo()
  instead of exposing header in local header "sys-socket.h"
2017-03-28 02:17:33 -04:00
Glenn Strauss 4796313efc [core] collect ioctl FIONREAD code
include <sys/ioctl.h> in files which use ioctl()
  instead of exposing header in local header "sys-socket.h"
2017-03-28 02:17:33 -04:00
Glenn Strauss e116479731 [core] make stat_cache private to stat_cache.c 2017-03-28 02:17:33 -04:00
Glenn Strauss ba953cdf45 [core] include "fdevent.h" where needed
(instead of providing #include "fdevent.h" in base.h)
2017-03-28 02:17:33 -04:00
Glenn Strauss 20ed025685 [core] use con->dst_addr_buf instead of ip recalc
use con->dst_addr_buf over inet_ntop_cache_get_ip(srv, &(con->dst_addr))
2017-03-28 02:17:33 -04:00
Glenn Strauss a53f662a30 [core] remove some unused header includes
remove exposure of stdio.h in buffer.h for print_backtrace(), now static
2017-03-28 02:17:33 -04:00
Glenn Strauss 14890c1c89 [core] remove redundant Content-Length digit check 2017-03-23 21:18:15 -04:00
Glenn Strauss 4115266792 [mod_proxy] set X-Forwarded-Host (fixes #418)
lighttpd appends the request "Host" to the non-standard header "X-Host"
when acting as a reverse proxy.  This patch additionally appends "Host"
to the non-standard header "X-Forwarded-Host" to match the convention in
some other web servers

x-ref:
  "mod_proxy should send the X-Forwarded-Host header to the proxied server"
  https://redmine.lighttpd.net/issues/418
2017-03-23 12:44:57 -04:00
Glenn Strauss 37261bbd7e [mod_proxy] set Content-Length, if available
set Content-Length if client sent Transfer-Encoding: chunked
and not streaming to backend (request body has been fully received)
2017-03-23 12:43:38 -04:00
Philip Prindeville 367e62c1c2 [core] allow overriding prior config values (fixes #2799)
introduce ":=" config file syntax to replace previously set value

github: closes #78

x-ref:
  "allow overriding configuration values"
  https://redmine.lighttpd.net/issues/2799
  https://github.com/lighttpd/lighttpd1.4/pull/78
2017-03-23 01:29:05 -04:00
Glenn Strauss ad6c703a51 [core] server.syslog-facility (use -1 for unset) (#2800)
(thx philipp)

x-ref:
  "lighttpd needs config option for syslog facility"
  https://redmine.lighttpd.net/issues/2800
2017-03-20 20:28:49 -04:00
Glenn Strauss a8561450a5 [core] server.syslog-facility (fixes #2800)
server.syslog-facility = "daemon"

x-ref:
  "lighttpd needs config option for syslog facility"
  https://redmine.lighttpd.net/issues/2800
2017-03-19 23:48:50 -04:00
Glenn Strauss aa14493e47 [tests] reduce time waiting for backends to start
reduce time spent waiting for backends to start

tests check for active listening port before proceeding

test runs now complete in about 2/3 the time
2017-03-19 23:48:50 -04:00
Glenn Strauss 1804ccbd6d [mod_scgi] do not reconnect after connect succeeds
apply diff from commit:2eaf42d0 made to mod_fastcgi.c back in 2009

(change is being made for (a bit more) consistency between the modules
 as mod_scgi.c was forked from mod_fastcgi.c a very long time ago, as
 well as to remove call to sleep for 10ms (usleep(10000) from mod_scgi)

x-ref:
  "fastcgi incomplete header might crash lighty"
  https://redmine.lighttpd.net/issues/2096
2017-03-19 23:48:50 -04:00
Glenn Strauss 3b7ab403be [mod_cgi] eliminate warning when compiled -Os 2017-03-19 23:48:50 -04:00
Glenn Strauss a22c126323 [core] remove now-unused buffer_search_string_len
(just use strstr(), if desired)
2017-03-19 23:48:50 -04:00
Glenn Strauss 0a635fc8be [core] consolidate dynamic handler response parse
- consolidate dynamic handler HTTP response parsing code
- reduce string copies for CGI, FastCGI, SCGI, proxy response headers
- let read() signal EOF or EAGAIN instead of ioctl FIONREAD 0-data-ready
2017-03-19 23:48:50 -04:00
Glenn Strauss 76ad82434f [mod_proxy] remove use of con->got_response 2017-03-15 13:19:18 -04:00
Glenn Strauss 0ec41d6d80 [core] remove unused member con->in_joblist 2017-03-15 13:16:13 -04:00
Glenn Strauss 1485cb401b [core] fix crash if invalid config file (fixes #2798)
If lighttpd.conf is invalid, some modules may not have initialized their
per-context config structures, but will have their free-functions
called, which should not be run on uninitialized per-context configs.

x-ref:
  "Segfault with simple-vhost.debug = "enable""
  https://redmine.lighttpd.net/issues/2798
2017-03-13 19:30:09 -04:00
Glenn Strauss 46ff978fa0 [doc] simple-vhost.debug takes an integer value (fixes #2797) 2017-03-13 13:50:07 -04:00
Glenn Strauss 83759aede6 [mod_auth] Digest nonce on system with time <=1978
On systems with time prior to Jul 4 1978 21:24:15,
the hex string of the timestamp is fewer than 8 chars.

(thx daveoman)
2017-03-13 13:50:07 -04:00
Glenn Strauss e4bb56222f [mod_cgi,fastcgi,scgi,proxy] fix streaming response (fixes #2796)
fix streaming response when server.stream-response-body = 2
and client catches up to stream from backend

(thx horgh)

x-ref:
  "mod_fastcgi can fail to read entire response from server"
  https://redmine.lighttpd.net/issues/2796
2017-03-13 13:49:17 -04:00
Glenn Strauss f94d666d15 [mod_authn_gssapi] needs -lcom_err under cygwin 2017-03-10 02:42:35 -05:00
Glenn Strauss bd77abe0f8 [config] more specific checks for array lists
More specific checks on contents of array lists.  Each module using
lists now does better checking on the types of values in the list
(strings, integers, arrays/lists)

This helps prevent misconfiguration of things like cgi.assign,
fastcgi.server, and scgi.server, where source code might be
served as static files if parenthesis are misplaced.

x-ref:
  https://redmine.lighttpd.net/boards/2/topics/6571
2017-03-08 11:42:59 -05:00
Glenn Strauss 970f337c29 [core] reduce con allocation for small max_conns
reduce con allocation for small server.max_conns
(do not allocate structures that will never be used)
2017-03-01 19:21:04 -05:00
Glenn Strauss 18905bca2b update .gitignore, add .gitattributes 2017-02-28 12:01:53 -05:00
Glenn Strauss 3399b0dd16 [core] default server.max-fds=4096 if unspecified (#2789)
x-ref:
  "lighttpd cores on AIX when nofiles is unlimited"
  https://redmine.lighttpd.net/issues/2789
2017-02-28 11:34:04 -05:00
Glenn Strauss 8ddb727d5c [mod_usertrack] usertrack.cookie-attrs config opt (fixes #2795)
usertrack.cookie-attrs allows user to add arbitrary attributes to the
  cookie set by mod_usertrack, including attributes Secure and HttpOnly
  as well as Path

usertrack.cookie-attrs is appended as-is to cookie string
  and therefore must be properly URL-encoded

usertrack.cookie-attrs, if set, replaces *all* other cookie attributes,
  including "; Path=/; Version=1" as well as the Domain= and Max-Age=
  attributes if usertrack.cookie-domain and usetrack.cookie-max-age set,
  so those should be part of usertrack.cookie-attrs if desired

e.g.
  usertrack.cookie-name  = "TRACKID"    # (default)
  usertrack.cookie-attrs = "; Path=/; Version=1; Domain=mydom.com; Max-Age=86400; Secure; HttpOnly"

x-ref:
  "mod_usertrack should have an option to set the 'Secure' and 'HttpOnly' flags on the cookie"
  https://redmine.lighttpd.net/issues/2795
2017-02-27 12:16:32 -05:00
Glenn Strauss 78047a3c1b [core] $REQUEST_HEADER[...] subsumes other config (#1556)
x-ref:
  "Allow matching against any arbitrary HTTP header in the configuration file regexps"
  https://redmine.lighttpd.net/issues/1556
2017-02-27 02:05:56 -05:00
Glenn Strauss 57ab20ace5 [mod_cgi] cgi.local-redir = [enable|disable] (#2108, #2793)
new directive cgi.local-redir = [enable|disable]

*disable* RFC3875 6.2.2 local-redir by default.
(behavior change from when local-redir support added in lighttpd 1.4.40)

The reason for this behavior change is that CGI local-redir support
(RFC3875 6.2.2) is an optimization.  Absence of support may result in
additional latency in servicing a request due the additional round-trip
to the client, but that was the prior behavior (before lighttpd 1.4.40)
and is the behavior of web servers which do not support CGI local-redir.

However, enabling CGI local-redir by default may result in broken links
in the case where a user config (unaware of CGI local-redir behavior)
returns HTML pages containing *relative* paths (not root-relative paths)
which are relative to the location of the local-redir target document,
and the local-redir target document is located at a different URL-path
from the original CGI request.

x-ref:
  RFC3875 CGI 1.1 specification section 6.2.2 Local Redirect Response
  http://www.ietf.org/rfc/rfc3875
  "CGI local redirect not implemented correctly"
  https://redmine.lighttpd.net/issues/2108
  "1.4.40 regression: broken redirect (using Location) between url.rewrite-once URLs"
  https://redmine.lighttpd.net/issues/2793
2017-02-26 18:03:10 -05:00
Glenn Strauss d569572112 [mod_vhostdb_ldap] fix inverted logic (coverity)
fix inverted logic identified by coverity

silence other coverity warnings
2017-02-26 10:54:43 -05:00
Glenn Strauss ab077790f2 [tests] correct skip count for mod-scgi.t 2017-02-25 16:02:50 -05:00
Glenn Strauss 350d39b4ca [core] fix regex condition subst w/ mod_extforward (fixes #2794)
x-ref:
  "1.4.40 regression: regexp subst vars mangled by config-glue condition caching"
  https://redmine.lighttpd.net/issues/2794
2017-02-25 12:41:21 -05:00
Glenn Strauss 51ff7ac504 [mod_cgi] status 200 OK if no hdrs (deprecated) (#2786)
set status 200 OK if CGI does not return CGI headers

Note:
This mode in lighttpd is deprecated and may be removed in the next major
release of lighttpd.  CGI scripts should return a proper CGI header in
the response, even if that header is empty and followed by a blank line,
before return response body.

Without a proper CGI response header, the first line(s) of the response
might be incorrectly construed as being CGI response headers, especially
if they contain ':', and response may be corrupted.  That is why this
mode is deprecated (and not supported in numerous other web servers).

The minimal valid CGI response header is "\n", which lighttpd will treat
as equivalent to "Status: 200\n\n"

x-ref:
  "error 500 (mod_cgi.c.601) cgi died"
  https://redmine.lighttpd.net/issues/2786
2017-02-25 12:41:21 -05:00
Glenn Strauss 1dd5cce3bc [mod_fastcgi,mod_scgi] consolidate backend process accounting (#2788)
consolidate backend process accounting for consistency

x-ref:
  "FreeBSD/1.4.45/SSL: requests getting stuck in handle-req state occasionally"
  https://redmine.lighttpd.net/issues/2788
2017-02-25 12:41:21 -05:00
Glenn Strauss 23c3535efc [mod_scgi] fix potential repeated use of proc->id
host->max_id is now number of procs allocated
proc->id is used when generated unix socket name or port for proc
2017-02-25 12:41:21 -05:00
Glenn Strauss 317b7e5fc6 [mod_scgi] fix unused_procs bidirectional-links 2017-02-25 12:41:20 -05:00
Glenn Strauss ab85841b14 [mod_cgi] fix CGI local-redir w/ url.rewrite-once (fixes #2793)
x-ref:
  "1.4.40 regression: broken redirect (using Location) between url.rewrite-once URLs"
  https://redmine.lighttpd.net/issues/2793
2017-02-25 12:41:20 -05:00
Glenn Strauss fb6b4027c8 [mod_fastcgi,mod_scgi] consistent waitpid handling (fixes #2791)
more consistent waitpid() handling, consolidate similar code

If ECHILD received for a given pid, do not retry waitpid() for that pid

x-ref:
  "mod_fastcgi : pid {pid} 1 not found: No child processes"
  https://redmine.lighttpd.net/issues/2791
2017-02-25 12:41:18 -05:00
Glenn Strauss 95a756dcb3 [core] issue trace if max-fds too large (fixes #2789)
x-ref:
  "lighttpd cores on AIX when nofiles is unlimited"
  https://redmine.lighttpd.net/issues/2789
2017-02-13 14:24:53 -05:00
Glenn Strauss daa94fceee [core] move version.h logic into server.c
and remove version.h
2017-02-12 00:55:44 -05:00