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 CEA34109D5 for ; Thu, 19 Sep 2013 19:10:30 +0000 (UTC) Received: (qmail 44387 invoked by uid 500); 19 Sep 2013 19:10:30 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 44291 invoked by uid 500); 19 Sep 2013 19:10:29 -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 44220 invoked by uid 99); 19 Sep 2013 19:10:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Sep 2013 19:10:27 +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 (athena.apache.org: domain of sorinm@gmail.com designates 74.125.82.53 as permitted sender) Received: from [74.125.82.53] (HELO mail-wg0-f53.google.com) (74.125.82.53) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Sep 2013 19:10:21 +0000 Received: by mail-wg0-f53.google.com with SMTP id x12so8509517wgg.20 for ; Thu, 19 Sep 2013 12:10:00 -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=hQ006Q2fvafRpA7sQNmilUMWxyFZAKVcrSc/pKXtx6g=; b=wbt7F1y4k7rfyXmUGvErKUimhSgCJypCMAUpVo2YMzpxzkTXUK0UHRiO9gyTA47Wy1 DEd+pYdh+UiwmWBo8p+AP7aacOjGCyTCVCv7I1ZeACuPLbZ8+gvTkbrQ5uAz9fq5c5Xd h2U86gCk0Pwsw0gROeicyUxdsRzcY2gxm/e5YfNu8jS1iLgSjPW9Dc9P4p1ovrG5spuN ErdT8ZGt8ScFg2M2BgHCWzAyhJHSLCqQYAm/h9noObb20kh6XwFYgPx91ZIPqIShJndm N+zqJQLc0rgLUygZEeSEj8nhqRwdzD0FSg1Km5Wnbi5f5J1YLL5WeAbUn2ZHPeSOfHe3 B6Zg== X-Received: by 10.180.182.15 with SMTP id ea15mr12801662wic.16.1379617800266; Thu, 19 Sep 2013 12:10:00 -0700 (PDT) Received: from ?IPv6:2a01:e35:8b73:8dd0:762f:68ff:fee5:8d8? ([2a01:e35:8b73:8dd0:762f:68ff:fee5:8d8]) by mx.google.com with ESMTPSA id q5sm12063772wiz.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Sep 2013 12:09:59 -0700 (PDT) Message-ID: <523B4C01.8050009@gmail.com> Date: Thu, 19 Sep 2013 21:09:53 +0200 From: Sorin Manolache User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130821 Icedove/17.0.8 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> In-Reply-To: <20130919163919.4a7c2b27@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-19 16:39, Christoph Gr�ver wrote: > > Hello, > > We usually use name based virtualhosts with something like the following > configuration: > > NameVirtualHost IP:80 > > > ServerName main.domain.tld > ServerAlias alias.domain.tld > > .. > > > > ServerName www.domain.tld > ServerAlias alt.domain.tld > .. > I've tested this setup in 2.4.6 and r->server->server_hostname contains what you want. Regards, Sorin > > Now I'm looking for a function which reliable returns the > host main.domain.tld if the first vhost is used (even if > it is used as alias.domain.tld) and returns www.domain.tld > if the second one is used (even if under the name alt.domain.tld). > > > I know of two ways to do this: > > 1. ap_get_server_name > > This returns the right hostname if "UseCanonicalName" is set. > But returns just the Host:-Header if it is off - which is the default. > > 2. server_rec structure > > The element server->server_hostname always returns the first vhost > available for an ip address. So even if I use www.domain.tld it returns > main.domain.tld > > So the first option depends on "UseCanonicalName", the second does > something else - which is not what I want. > > Any other ways of doing this? > Or is there just the solution to force "UseCanonicalName" to "on" > and otherwise it won't work. > > Can anybody enlighten me as to how this should be done? > > Thank you, Greetings >