summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2017-03-16 10:18:11 +0000
committerflorian <florian@openbsd.org>2017-03-16 10:18:11 +0000
commit11d703aaf156f49038eab4919b7473f38554a2c3 (patch)
treef53a2c8f532089ec49418f4f69d7db11d496c0fb /usr.sbin/httpd
parentDo not allow to change the gateway of an existing entry if the AF (diff)
downloadwireguard-openbsd-11d703aaf156f49038eab4919b7473f38554a2c3.tar.xz
wireguard-openbsd-11d703aaf156f49038eab4919b7473f38554a2c3.zip
Expand $HTTP_HOST in redirects.
From Rivo Nurges Rivo.Nurges AT smit.ee, thanks! OK reyk
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/httpd.conf.56
-rw-r--r--usr.sbin/httpd/server_http.c10
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,