Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7FEAF10CD4 for ; Tue, 24 Sep 2013 10:14:41 +0000 (UTC) Received: (qmail 26622 invoked by uid 500); 24 Sep 2013 09:58:18 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 26440 invoked by uid 500); 24 Sep 2013 09:58:02 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 26219 invoked by uid 99); 24 Sep 2013 09:57:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 09:57:37 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sorinm@gmail.com designates 209.85.212.173 as permitted sender) Received: from [209.85.212.173] (HELO mail-wi0-f173.google.com) (209.85.212.173) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 09:57:31 +0000 Received: by mail-wi0-f173.google.com with SMTP id hq15so3509538wib.0 for ; Tue, 24 Sep 2013 02:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Z7vChCKaW8w33C/09CfzHcQt7zCb53KTCq02be7BTeM=; b=cvEVL3v1QKDdKzbTljmMP33PJBamdt4za/1zi5NEUW99BU4BDbeIsbBqlxN7+7/4G2 HMj96EzOtUrF6CkXsx9xpaMojzUPZpHZubuppQlfu5rkGW+IxhcDbNgTDWdNmLxQJ6s7 4vjhpOsztzar8c9mouM6ul/uy/pTAVJd2qqzod7+UXbrpgMetiHotkvmFUs2TKH7BmVm tueClO0wZ9aXy91cI+L2bvuN9I+aNdsO6iCtr6R6NRtGq/cAw8VH2nFhzX1hZckaL6Rt 7NKcDibeAobSdaHCGvmS4/r2aHmtXZxfz/w9vPpAErPlCxzT8CNxIQxA+3QPDqm8PR4h C6wA== X-Received: by 10.180.206.244 with SMTP id lr20mr17168895wic.45.1380016631074; Tue, 24 Sep 2013 02:57:11 -0700 (PDT) Received: from ?IPv6:2a01:c9c0:a1:15:213:72ff:fe38:2e23? ([2a01:c9c0:a1:15:213:72ff:fe38:2e23]) by mx.google.com with ESMTPSA id dx7sm5835039wib.8.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Sep 2013 02:57:10 -0700 (PDT) Message-ID: <524161F3.5050209@gmail.com> Date: Tue, 24 Sep 2013 11:57:07 +0200 From: Sorin Manolache User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: How to determine the "right" vhost in name based vhosting References: <20130919163919.4a7c2b27@aeshna.sitepark.local> <523B4C01.8050009@gmail.com> <20130924113831.053b561c@aeshna.sitepark.local> In-Reply-To: <20130924113831.053b561c@aeshna.sitepark.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org On 2013-09-24 11:38, Christoph Gr�ver wrote: > > Hello list, Hello Sorin, > > I tested several different Apaches (2.4.x and 2.2.x) and they never did > the wanted or expected. > > If I configure more than one VHost only the first one is returned by > the server->server_hostname structure. > The one of the second vhost that is configured as a "ServerName" seems > to be impossible to determine? > > Is there any other way to find the hostname? I suppose you use the server field of the request_rec structure and not some stored server_rec that was passed to you in post_config or somewhere else. Apache keeps a linked list of server_rec structures. The head of the list is the server_rec of the whole apache server. The rest of the list contains one server_rec structure per vhost. For each request apache picks the right server_rec from the list according to the Host header and sets r->server to point to the picked object. Also make sure that your request really arrives in the vhost you intended. Typically I check this by logging to different files (see the CustomLog directive) in each vhost. Regards, Sorin