You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Fred Zinsli <fr...@shooter.co.nz> on 2009/06/09 03:12:00 UTC
[users@httpd] default site
Hello all
I am sure this has been asked, but I couldn't find the answer I was
looking for.
I have apache 2.2 installed on my Debian server with name based virtual
hosting. Single static IP.
I have my DNS setup as wildcard left of the domain *.shooter.co.nz
I have setup the websites I wanted using individual conf files and they
all work well.
But when I type any other URL apart from those configured I get the
default "Its working" page.
How can I point all other URLs not defined to a default site?
The thing to concider is that I have phpmysql installed which is only
accessable via the local (192.168.*.*)IP of the machine from inside the
LAN. It is not accessable from a name based URL.
I wasn't sure if it was just a case of setting the default document root
or not, but then I would probably loss my phpmysql accesss as the
document path would be invalid for that application.
This is on a production server with 8 websites so hence I am cautious
about any changes on it.
Any comments or pointers to documentation on this subject would be most
helpful.
Regards
Fred
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] default site
Posted by Boyle Owen <Ow...@six-group.com>.
> -----Original Message-----
> From: Davide Bianchi [mailto:davide@walterisookeensufferukker.nl]
>
> Actually no. If the request doesn't match any Virtual Hosts,
> it will be
> served by the first vhost defined or by the one defined with the
> _default_ keyword.
Quite right. Once you start using VHs, external DocRoots are ignored. So
the OP's "It works!" page must be coming from the first or default VH.
Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.
>
> Davide
>
> --
> You need an emergency cynicism transplant, stat.
> -- Seymour J. on asr
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message.
The sender's company reserves the right to monitor all e-mail communications through their networks.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] default site
Posted by "Singh, Sukhjeet" <su...@fiserv.com>.
Eric,
Basically the thing is my security guy is saying that If I can any how able to fix the 404 error in lieu of the 403 Forbidden error then it'll fix the vulnerability.
I mean instead of HTTP/1.1 403 I should get HTTP/1.1 404 while anyone try even from telnet or with any scanner.
Sukhjeet Singh
Project Lead
Fiserv Global Services
Fiserv
Office: +91-120-4023086
Mobile: 9999991422
US: 1-877-271-3943 x 3086
www.fiserv.com
-----Original Message-----
From: Eric Covener [mailto:covener@gmail.com]
Sent: Wednesday, June 10, 2009 5:37 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] default site
On Wed, Jun 10, 2009 at 4:07 AM, Matus UHLAR - fantomas
<uh...@fantomas.sk> wrote:
>> NameVirtualHost doesn't affect this selection, so the logic degrades
>> to simpler _default_ and * are used when there isn't an exact match
>> on the IP.
>
> I've meant, if there's NameVirtualHost <ip>, the <VirtualHost _default_>
> will not match the IP even if there's no virtual host on that IP defined.
> Was I wrong?
AFAICT the _default_ vhost matches in this case -- the request is not
handled by the "base" config.
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by Eric Covener <co...@gmail.com>.
On Wed, Jun 10, 2009 at 4:07 AM, Matus UHLAR - fantomas
<uh...@fantomas.sk> wrote:
>> NameVirtualHost doesn't affect this selection, so the logic degrades
>> to simpler _default_ and * are used when there isn't an exact match
>> on the IP.
>
> I've meant, if there's NameVirtualHost <ip>, the <VirtualHost _default_>
> will not match the IP even if there's no virtual host on that IP defined.
> Was I wrong?
AFAICT the _default_ vhost matches in this case -- the request is not
handled by the "base" config.
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
> > On 09.06.09 09:14, Davide Bianchi wrote:
> >> Actually no. If the request doesn't match any Virtual Hosts, it will be
> >> served by the first vhost defined or by the one defined with the
> >> _default_ keyword.
> On Tue, Jun 9, 2009 at 4:11 AM, Matus UHLAR - fantomas
> <uh...@fantomas.sk> wrote:
> > No. The "first vhost defined" matches name virtual host on the same IPs.
> >
> > the _default_ host matches all IP's that have no vhost configured and are
> > not configured to have name-based viurtual hosts (read: no <VirtualHost> nor
> > NameVirtualHost use them).
On 09.06.09 07:53, Eric Covener wrote:
> NameVirtualHost doesn't affect this selection, so the logic degrades
> to simpler _default_ and * are used when there isn't an exact match
> on the IP.
I've meant, if there's NameVirtualHost <ip>, the <VirtualHost _default_>
will not match the IP even if there's no virtual host on that IP defined.
Was I wrong?
> Any name-based vhost selection will happen after this is already
> sorted out, if the VirtualHost selected (in the ip-based phase where
> _default_ and * will be compared to anything) matches exactly an NVH.
--
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
The early bird may get the worm, but the second mouse gets the cheese.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by André Warnier <aw...@ice-sa.com>.
Eric Covener wrote:
> On Tue, Jun 9, 2009 at 4:11 AM, Matus UHLAR - fantomas
> <uh...@fantomas.sk> wrote:
>>> Boyle Owen wrote:
...
Amazing how this can get confused quickly, no ?
;-)
My version :
-- begin of main configuration file (say httpd.conf) ---
directives..
more directives...
...
Listen 80
...
NameVirtualHost *:80
# first Virtual Host
<VirtualHost *:80>
ServerName whatever_you_want # and doesn't matter, see below
....
....
</VirtualHost>
# 2d virtual host
<VirtualHost *:80>
# the following name *must* be a real DNS name, resolving to the IP
# address of this Apache server host
ServerName server1.company1.com
....
....
</VirtualHost>
# 3d virtual host
<VirtualHost *:80>
# the following name *must* be a real DNS name, resolving to the IP
# address of this Apache server host
ServerName server2.company1.com
....
....
</VirtualHost>
# 4th virtual host
<VirtualHost *:80>
# the following name *must* be a real DNS name, resolving to the IP
# address of this Apache server host
ServerName server1.company2.com
....
....
</VirtualHost>
etc..
# nth virtual host
<VirtualHost *:80>
# the following name *must* be a real DNS name, resolving to the IP
# address of this Apache server host
ServerName servern.companym.com
....
....
</VirtualHost>
Principles :
0) do not mix IP-based and name-based virtual hosts. That gets quite
complicated, as you've seen before. So forget about the _default_ host.
Pretend you've never heard about it.
1) whatever Directive is located in the "main" part of the
configuration, acts as a default for all virtual hosts.
That is, if a given <VirtualHost> section above does not re-define the
same Directive, then it inherits it from the main configuration.
But the main configuration is /not/ a host. It is just a "container"
for these default directives.
2) When a request comes in to this server (and it will only come in if
the DNS name points to this IP address), Apache tries to match the
hostname indicated in the request, with each of the ServerName
directives above, in the order in which the <VirtualHost> sections
appear in the configuration.
3) If it succeeds (meaning there is a match), then Apache "adopts the
personality" of that <VirtualHost> to process the request.
It's the same Apache process, no matter which personality it adopts.
But each personality comes with a different setup (the one composed of
the default main directives, overridden by the ones in the selected
<VirtualHost> section).
4) if it does not succeed (no match between the request hostname and a
ServerName directive), then Apache adopts the personality of the *first*
<VirtualHost> section above, no matter which "ServerName" that one
contains. That is why basically the first ServerName does not matter
(all that much), because anything Apache cannot match, will end up there.
5) Of course if you want requests to "127.0.0.1" and "localhost" (as a
hostname in e.g. "http://localhost" to be processed by a specific
virtual host different from the default, then add a specific
<VirtualHost> section as follows, *after* the first one :
<VirtualHost *:80>
ServerName localhost
ServerAlias 127.0.0.1
...
</VirtualHost>
thus 6) if you want one <VirtualHost> section to match more than one DNS
hostname, then use ServerName for the first name, and ServerAlias for
the other one(s).
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by Eric Covener <co...@gmail.com>.
On Tue, Jun 9, 2009 at 4:11 AM, Matus UHLAR - fantomas
<uh...@fantomas.sk> wrote:
>> Boyle Owen wrote:
>> > However, a request with a domain-name that *doesn't* match a VH will be
>> > served outside the VHs by whatever default rules you have (look for
>> > "ServerName" and "DocumentRoot" outside any VH).
>
> On 09.06.09 09:14, Davide Bianchi wrote:
>> Actually no. If the request doesn't match any Virtual Hosts, it will be
>> served by the first vhost defined or by the one defined with the
>> _default_ keyword.
>
> No. The "first vhost defined" matches name virtual host on the same IPs.
>
> the _default_ host matches all IP's that have no vhost configured and are
> not configured to have name-based viurtual hosts (read: no <VirtualHost> nor
> NameVirtualHost use them).
NameVirtualHost doesn't affect this selection, so the logic degrades
to simpler _default_ and * are used when there isn't an exact match
on the IP.
Any name-based vhost selection will happen after this is already
sorted out, if the VirtualHost selected (in the ip-based phase where
_default_ and * will be compared to anything) matches exactly an NVH.
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
> Boyle Owen wrote:
> > However, a request with a domain-name that *doesn't* match a VH will be
> > served outside the VHs by whatever default rules you have (look for
> > "ServerName" and "DocumentRoot" outside any VH).
On 09.06.09 09:14, Davide Bianchi wrote:
> Actually no. If the request doesn't match any Virtual Hosts, it will be
> served by the first vhost defined or by the one defined with the
> _default_ keyword.
No. The "first vhost defined" matches name virtual host on the same IPs.
the _default_ host matches all IP's that have no vhost configured and are
not configured to have name-based viurtual hosts (read: no <VirtualHost> nor
NameVirtualHost use them).
--
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Honk if you love peace and quiet.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] default site
Posted by Davide Bianchi <da...@walterisookeensufferukker.nl>.
Boyle Owen wrote:
> However, a request with a domain-name that *doesn't* match a VH will be
> served outside the VHs by whatever default rules you have (look for
> "ServerName" and "DocumentRoot" outside any VH).
Actually no. If the request doesn't match any Virtual Hosts, it will be
served by the first vhost defined or by the one defined with the
_default_ keyword.
Davide
--
You need an emergency cynicism transplant, stat.
-- Seymour J. on asr
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] default site
Posted by Fred Zinsli <fr...@shooter.co.nz>.
Thank you
The ServerAlias directive worked a treat.
As Apache 2.2 uses separate conf files for each vhost I set the www conf
on all domains to appear at the end of the file order and placed a
wildcard ServerAlias directive after the ServerName directive.
serverName www.shooter.co.nz
ServerAlias *.shooter.co.nz
Now everything left of the domain that is not configured goes to
www.<domain-name>
And gladly I still have access to my phpmyadmin for sql management.
Thanks to all those who provided comments, they were all helpful.
Regards
Fred
-----Original Message-----
From: "Boyle Owen" <Ow...@six-group.com>
To: <us...@httpd.apache.org>
Date: Tue, 9 Jun 2009 09:10:23 +0200
Subject: RE: [users@httpd] default site
> > -----Original Message-----
> > From: Fred Zinsli [mailto:fred.zinsli@shooter.co.nz]
> > Sent: Tuesday, June 09, 2009 3:12 AM
> > To: users@httpd.apache.org
> > Subject: [users@httpd] default site
> >
> > Hello all
> >
> > I am sure this has been asked, but I couldn't find the answer I was
> > looking for.
> >
> > I have apache 2.2 installed on my Debian server with name
> > based virtual
> > hosting. Single static IP.
> >
> > I have my DNS setup as wildcard left of the domain *.shooter.co.nz
> > I have setup the websites I wanted using individual conf
> > files and they
> > all work well.
> >
> > But when I type any other URL apart from those configured I get the
> > default "Its working" page.
> >
> > How can I point all other URLs not defined to a default site?
>
> Since you have defined name-based VHs, all requests that match a
> defined
> domain-name will end up in the appropriate VH. That, you say, is
> working..
>
> However, a request with a domain-name that *doesn't* match a VH will be
> served outside the VHs by whatever default rules you have (look for
> "ServerName" and "DocumentRoot" outside any VH).
>
> The simplest fix is probably to pick a "default" VH and then assign all
> unmatched domains to it using the "ServerAlias" directive. Something
> like;
>
> <VH ip:80>
> ServerName www1.shooter.co.nz
> ServerAlias *.shooter.co.nz
> ...
>
> VHs are matched in config file order so the default one (containing
> "ServerAlias *.shooter.co.nz") should be last.
>
> NB: requests with *no* domain name (eg http://121.73.6.17/) will still
> go outside the VHs, to fix that, use "ServerAlias *", if that's what
> you
> want. Or edit the external DocumentRoot directive to point to some
> error
> page.
>
> Rgds,
> Owen Boyle
> Disclaimer: Any disclaimer attached to this message may be ignored.
>
>
>
>
>
> >
> > The thing to concider is that I have phpmysql installed which is only
> > accessable via the local (192.168.*.*)IP of the machine from
> > inside the
> > LAN. It is not accessable from a name based URL.
> >
> > I wasn't sure if it was just a case of setting the default
> > document root
> > or not, but then I would probably loss my phpmysql accesss as the
> > document path would be invalid for that application.
> >
> > This is on a production server with 8 websites so hence I am cautious
> > about any changes on it.
> >
> > Any comments or pointers to documentation on this subject
> > would be most
> > helpful.
> >
> > Regards
> >
> > Fred
> >
> >
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP
> > Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > " from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
>
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. If you
> receive this message in error, please notify the sender urgently and
> then immediately delete the message and any copies of it from your
> system. Please also immediately destroy any hardcopies of the message.
> The sender's company reserves the right to monitor all e-mail
> communications through their networks.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] default site
Posted by Boyle Owen <Ow...@six-group.com>.
> -----Original Message-----
> From: Fred Zinsli [mailto:fred.zinsli@shooter.co.nz]
> Sent: Tuesday, June 09, 2009 3:12 AM
> To: users@httpd.apache.org
> Subject: [users@httpd] default site
>
> Hello all
>
> I am sure this has been asked, but I couldn't find the answer I was
> looking for.
>
> I have apache 2.2 installed on my Debian server with name
> based virtual
> hosting. Single static IP.
>
> I have my DNS setup as wildcard left of the domain *.shooter.co.nz
> I have setup the websites I wanted using individual conf
> files and they
> all work well.
>
> But when I type any other URL apart from those configured I get the
> default "Its working" page.
>
> How can I point all other URLs not defined to a default site?
Since you have defined name-based VHs, all requests that match a defined
domain-name will end up in the appropriate VH. That, you say, is
working..
However, a request with a domain-name that *doesn't* match a VH will be
served outside the VHs by whatever default rules you have (look for
"ServerName" and "DocumentRoot" outside any VH).
The simplest fix is probably to pick a "default" VH and then assign all
unmatched domains to it using the "ServerAlias" directive. Something
like;
<VH ip:80>
ServerName www1.shooter.co.nz
ServerAlias *.shooter.co.nz
...
VHs are matched in config file order so the default one (containing
"ServerAlias *.shooter.co.nz") should be last.
NB: requests with *no* domain name (eg http://121.73.6.17/) will still
go outside the VHs, to fix that, use "ServerAlias *", if that's what you
want. Or edit the external DocumentRoot directive to point to some error
page.
Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.
>
> The thing to concider is that I have phpmysql installed which is only
> accessable via the local (192.168.*.*)IP of the machine from
> inside the
> LAN. It is not accessable from a name based URL.
>
> I wasn't sure if it was just a case of setting the default
> document root
> or not, but then I would probably loss my phpmysql accesss as the
> document path would be invalid for that application.
>
> This is on a production server with 8 websites so hence I am cautious
> about any changes on it.
>
> Any comments or pointers to documentation on this subject
> would be most
> helpful.
>
> Regards
>
> Fred
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message.
The sender's company reserves the right to monitor all e-mail communications through their networks.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org