diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2017-03-16 10:18:12 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2017-03-16 10:18:12 +0000 |
commit | f7e973c3951e28c619305d67145ccfb71ae73d29 (patch) | |
tree | f38f584763c8f6f1db375fd4cd9c0b5467a11d2f | |
parent | 9f23818f4a89ee83d5285d485a71a0c8596a011d (diff) |
Expand $HTTP_HOST in redirects.
From Rivo Nurges Rivo.Nurges AT smit.ee, thanks!
OK reyk
-rw-r--r-- | usr.sbin/httpd/httpd.conf.5 | 6 | ||||
-rw-r--r-- | usr.sbin/httpd/server_http.c | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5 index e4f9d4b4c26..05735332386 100644 --- a/usr.sbin/httpd/httpd.conf.5 +++ b/usr.sbin/httpd/httpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: httpd.conf.5,v 1.79 2017/02/07 12:27:42 reyk Exp $ +.\" $OpenBSD: httpd.conf.5,v 1.80 2017/03/16 10:18:11 florian Exp $ .\" .\" Copyright (c) 2014, 2015 Reyk Floeter <reyk@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 7 2017 $ +.Dd $Mdocdate: March 16 2017 $ .Dt HTTPD.CONF 5 .Os .Sh NAME @@ -221,6 +221,8 @@ The configured IP address of the server. The configured TCP server port of the server. .It Ic $SERVER_NAME The name of the server. +.It Ic $HTTP_HOST +The host from the HTTP Host header. .It Pf % Ar n The capture index .Ar n diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 7823c72ddca..d530c12c2d5 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.115 2017/03/10 21:06:43 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.116 2017/03/16 10:18:11 florian Exp $ */ /* * Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org> @@ -1068,6 +1068,14 @@ server_expand_http(struct client *clt, const char *val, char *buf, if (ret != 0) return (NULL); } + if (strstr(val, "$HTTP_HOST") != NULL) { + if (desc->http_host == NULL) + return (NULL); + if ((str = url_encode(desc->http_host)) == NULL) + return (NULL); + expand_string(buf, len, "$HTTP_HOST", str); + free(str); + } if (strstr(val, "$REMOTE_") != NULL) { if (strstr(val, "$REMOTE_ADDR") != NULL) { if (print_host(&clt->clt_ss, |