From: Art Cancro Date: Mon, 30 Jan 2006 17:11:01 +0000 (+0000) Subject: * When the -f option is specified, honor X-Forwarded-Host: in addition X-Git-Tag: v7.86~4251 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=78d99d2101a80d3be43211352b03fddfdd82bcd9;p=citadel.git * When the -f option is specified, honor X-Forwarded-Host: in addition to X-Forwarded-For: headers. This helps GroupDAV along. --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 01a426bc7..0233735b7 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,5 +1,9 @@ $Id$ +Mon Jan 30 12:09:00 EST 2006 ajc +* When the -f option is specified, honor X-Forwarded-Host: in addition + to X-Forwarded-For: headers. This helps GroupDAV along. + Mon Jan 30 00:14:06 EST 2006 ajc * HTML messages are now encoded as "Quoted-Printable" before being transmitted to the server. New utility function text_to_server_qp() diff --git a/webcit/README.txt b/webcit/README.txt index e35422e45..a530f5e29 100644 --- a/webcit/README.txt +++ b/webcit/README.txt @@ -125,7 +125,10 @@ the "webserver" program: "X-Forwarded-For:" HTTP headers which may be added if your WebCit service is sitting behind a front end proxy. This will allow users in your "Who is online?" list to appear as connecting from their actual host address - instead of the address of the proxy. + instead of the address of the proxy. In addition, the + "X-Forwarded-Host:" header from the front end proxy will also be honored, + which will help to make automatically generated absolute URL's (for + things like GroupDAV and mailing list subscriptions) correct. -> remotehost: the name or IP address of the host on which your Citadel server is running. The default is "localhost". diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index 46d467ec3..dd3fd7468 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -127,10 +127,15 @@ void groupdav_main(struct httprequest *req, for (rptr=req; rptr!=NULL; rptr=rptr->next) { /* lprintf(9, "< %s\n", rptr->line); */ + + /* + * We don't appear to need this; it was already done in webcit.c if (!strncasecmp(rptr->line, "Host: ", 6)) { safestrncpy(WC->http_host, &rptr->line[6], sizeof WC->http_host); } + */ + if (!strncasecmp(rptr->line, "If-Match: ", 10)) { safestrncpy(dav_ifmatch, &rptr->line[10], sizeof dav_ifmatch); diff --git a/webcit/webcit.c b/webcit/webcit.c index 1d9610c41..37289dea8 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1089,6 +1089,7 @@ void session_loop(struct httprequest *req) while (hptr != NULL) { safestrncpy(buf, hptr->line, sizeof buf); + lprintf(9, "HTTP HEADER: %s\n", buf); hptr = hptr->next; if (!strncasecmp(buf, "Cookie: webcit=", 15)) { @@ -1112,8 +1113,15 @@ void session_loop(struct httprequest *req) else if (!strncasecmp(buf, "User-agent: ", 12)) { safestrncpy(user_agent, &buf[12], sizeof user_agent); } + else if (!strncasecmp(buf, "X-Forwarded-Host: ", 18)) { + if (follow_xff) { + safestrncpy(WC->http_host, &buf[18], sizeof WC->http_host); + } + } else if (!strncasecmp(buf, "Host: ", 6)) { - safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host); + if (strlen(WC->http_host) == 0) { + safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host); + } } else if (!strncasecmp(buf, "X-Forwarded-For: ", 17)) { safestrncpy(browser_host, &buf[17], sizeof browser_host);