1 diff -ur lighttpd-1.4.8-o/doc/proxy.txt lighttpd-1.4.8/doc/proxy.txt
2 --- lighttpd-1.4.8-o/doc/proxy.txt 2005-08-10 16:26:16.000000000 -0600
3 +++ lighttpd-1.4.8/doc/proxy.txt 2006-01-10 01:55:04.000000000 -0700
5 :"host": is ip of the proxy server
6 :"port": is tcp-port on the "host" used by the proxy
8 + :"fix-redirects": rewrite redirects from proxied servers to reflect this
9 + server's hostname and port
13 diff -ur lighttpd-1.4.8-o/src/array.h lighttpd-1.4.8/src/array.h
14 --- lighttpd-1.4.8-o/src/array.h 2005-09-23 12:24:18.000000000 -0600
15 +++ lighttpd-1.4.8/src/array.h 2006-01-10 00:38:55.000000000 -0700
18 int usage; /* fair-balancing needs the no. of connections active on this host */
19 int last_used_ndx; /* round robin */
20 + short fix_redirects;
23 data_fastcgi *data_fastcgi_init(void);
24 diff -ur lighttpd-1.4.8-o/src/data_fastcgi.c lighttpd-1.4.8/src/data_fastcgi.c
25 --- lighttpd-1.4.8-o/src/data_fastcgi.c 2005-08-23 08:36:12.000000000 -0600
26 +++ lighttpd-1.4.8/src/data_fastcgi.c 2006-01-10 00:38:55.000000000 -0700
28 ds->host = buffer_init();
31 + ds->fix_redirects = 0;
33 ds->copy = data_fastcgi_copy;
34 ds->free = data_fastcgi_free;
35 diff -ur lighttpd-1.4.8-o/src/mod_proxy.c lighttpd-1.4.8/src/mod_proxy.c
36 --- lighttpd-1.4.8-o/src/mod_proxy.c 2005-11-18 05:29:36.000000000 -0700
37 +++ lighttpd-1.4.8/src/mod_proxy.c 2006-01-10 00:58:18.000000000 -0700
39 { "host", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
40 { "port", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
41 { "balance", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
42 + { "fix-redirects", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 3 */
43 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
48 pcv[0].destination = df->host;
49 pcv[1].destination = &(df->port);
50 + pcv[3].destination = &(df->fix_redirects);
52 if (0 != config_insert_values_internal(srv, da_host->value, pcv)) {
58 -static int proxy_response_parse(server *srv, connection *con, plugin_data *p, buffer *in) {
59 +static int proxy_response_parse(server *srv, connection *con, plugin_data *p, buffer *in, handler_ctx *hctx) {
61 int http_response_status = -1;
66 if (0 == strncasecmp(key, "Location", key_len)) {
68 con->parsed_response |= HTTP_LOCATION;
70 + host = buffer_init();
71 + buffer_copy_string_len(host, con->request.http_host, strchr(con->request.http_host->ptr, ':') - con->request.http_host->ptr);
73 + if(hctx->host->fix_redirects && strncmp(value, "http://", 7) == 0 && strncasecmp(value + 7, host->ptr, host->used) == 0 && *(value + 7 + host->used) == ':' && atoi(value + 7 + host->used + 1) == hctx->host->port) {
74 + value = strchr(value + 7 + host->used, '/');
82 log_error_write(srv, __FILE__, __LINE__, "sb", "Header:", hctx->response_header);
84 /* parse the response header */
85 - proxy_response_parse(srv, con, p, hctx->response_header);
86 + proxy_response_parse(srv, con, p, hctx->response_header, hctx);
88 /* enable chunked-transfer-encoding */
89 if (con->request.http_version == HTTP_VERSION_1_1 &&