diff options
author | Ruediger Pluem <rpluem@apache.org> | 2011-09-17 17:08:14 +0200 |
---|---|---|
committer | Ruediger Pluem <rpluem@apache.org> | 2011-09-17 17:08:14 +0200 |
commit | cfe0a63cd505edcbb33d9add4a009561ac66fb66 (patch) | |
tree | 232f89b76f13c05d9ae1792e9785eac307bd068e /server/vhost.c | |
parent | Fix cut'n'paste errors: APR_DECLARE -> AP_DECLARE / part2. (diff) | |
download | apache2-cfe0a63cd505edcbb33d9add4a009561ac66fb66.tar.xz apache2-cfe0a63cd505edcbb33d9add4a009561ac66fb66.zip |
* Correctly obey ServerName / ServerAlias if the Host header from the
request matches the VirtualHost address.
PR: 51709
Submitted by: Micha Lenk <micha lenk.info>
Reviewed by: rpluem
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172002 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | server/vhost.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/server/vhost.c b/server/vhost.c index e3a201a4dd..6b9f4be1b2 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -860,9 +860,11 @@ static void check_hostalias(request_rec *r) const char *host = r->hostname; apr_port_t port; server_rec *s; + server_rec *virthost_s; server_rec *last_s; name_chain *src; + virthost_s = NULL; last_s = NULL; port = r->connection->local_addr->port; @@ -889,23 +891,34 @@ static void check_hostalias(request_rec *r) s = src->server; - /* does it match the virthost from the sar? */ - if (!strcasecmp(host, sar->virthost)) { - goto found; - } - - if (s == last_s) { - /* we've already done ServerName and ServerAlias checks for this - * vhost - */ - continue; + /* If we still need to do ServerName and ServerAlias checks for this + * server, do them now. + */ + if (s != last_s) { + /* does it match any ServerName or ServerAlias directive? */ + if (matches_aliases(s, host)) { + goto found; + } } last_s = s; - if (matches_aliases(s, host)) { - goto found; + /* Fallback: does it match the virthost from the sar? */ + if (!strcasecmp(host, sar->virthost)) { + /* only the first match is used */ + if (virthost_s == NULL) { + virthost_s = s; + } } } + + /* If ServerName and ServerAlias check failed, we end up here. If it + * matches a VirtualHost, virthost_s is set. Use that as fallback + */ + if (virthost_s) { + s = virthost_s; + goto found; + } + return; found: |