You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rp...@apache.org on 2011/09/17 17:08:15 UTC
svn commit: r1172002 - in /httpd/httpd/trunk: CHANGES server/vhost.c
Author: rpluem
Date: Sat Sep 17 15:08:14 2011
New Revision: 1172002
URL: http://svn.apache.org/viewvc?rev=1172002&view=rev
Log:
* 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
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/server/vhost.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1172002&r1=1172001&r2=1172002&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Sep 17 15:08:14 2011
@@ -12,6 +12,10 @@ Changes with Apache 2.3.15
PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener,
<lowprio20 gmail.com>]
+ *) core: Correctly obey ServerName / ServerAlias if the Host header from the
+ request matches the VirtualHost address.
+ PR 51709. [Micha Lenk <micha lenk.info>]
+
*) mod_unique_id: Use random number generator to initialize counter.
PR 45110. [Stefan Fritsch]
Modified: httpd/httpd/trunk/server/vhost.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/vhost.c?rev=1172002&r1=1172001&r2=1172002&view=diff
==============================================================================
--- httpd/httpd/trunk/server/vhost.c (original)
+++ httpd/httpd/trunk/server/vhost.c Sat Sep 17 15:08:14 2011
@@ -860,9 +860,11 @@ static void check_hostalias(request_rec
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
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: