Discussion:
Apache2 Config - A little change
(too old to reply)
AndyXS
2012-06-14 05:55:51 UTC
Permalink
I need a little help with the latest apache v2. Basically my web server
has 1 IP address but hosts multiple websites. The configuration file
works just fine for this purpose as you will see from my config file below.

However when someone enters the servers IP address into their browser,
website1.com (in this example) is loading up. I do not want this to
happen. Instead I would like it to load a blank page, or a holding page
of some kind.

How do I do this?



NameVirtualHost 1.1.1.1

<VirtualHost 1.1.1.1>
ServerAdmin ***@localhost
ServerName website1.com
DocumentRoot /home/web1/public_html/

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory /home/web1/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog /home/web1/errors.log

LogLevel warn

CustomLog /home/web1/access.log combined
</VirtualHost>
Jim
2012-06-14 14:31:30 UTC
Permalink
On Thu, 14 Jun 2012 06:55:51 +0100, in alt.apache.configuration, AndyXS
Post by AndyXS
I need a little help with the latest apache v2. Basically my web server
has 1 IP address but hosts multiple websites. The configuration file
works just fine for this purpose as you will see from my config file below.
However when someone enters the servers IP address into their browser,
website1.com (in this example) is loading up. I do not want this to
happen. Instead I would like it to load a blank page, or a holding page
of some kind.
How do I do this?
Since you are using virtual hosts, you just need to add one. The first
virtual host in your config becomes the default. Any request that does
not match an existing virtual host is sent to the default virtual host.
It would appear that the first one is currently website1.com. Create a
virtual host that returns a blank page for every request and put it in
the config before the virtual host for website1.com.

HTH,
Jim
D. Stussy
2012-06-14 18:52:45 UTC
Permalink
"Jim" wrote in message news:***@mid.individual.net...


On Thu, 14 Jun 2012 06:55:51 +0100, in alt.apache.configuration, AndyXS
Post by AndyXS
I need a little help with the latest apache v2. Basically my web server
has 1 IP address but hosts multiple websites. The configuration file
works just fine for this purpose as you will see from my config file below.
However when someone enters the servers IP address into their browser,
website1.com (in this example) is loading up. I do not want this to
happen. Instead I would like it to load a blank page, or a holding page
of some kind.
How do I do this?
Since you are using virtual hosts, you just need to add one. The first
virtual host in your config becomes the default. Any request that does
not match an existing virtual host is sent to the default virtual host.
It would appear that the first one is currently website1.com. Create a
virtual host that returns a blank page for every request and put it in
the config before the virtual host for website1.com.

================================
Agreed as to how virtual hosts work, but I suggest returning something other
than a blank page. Some sort of index or local-site search page is a better
option and so is returning an error (404 or 501). I return 501 for virtual
hostnames which are not recognized and/or are not local to my web server.

Error 501 means "not implemented" - and I consider that as including requests
for unknown virtual hosts as well as unknown request methods on this basis:
If the virtual host is unknown, there are no known request methods for it.
One may think of 503 ("Service unavailable") but that error is for temporary
conditions, while this situation is a permanent error. However, if the
request comes in with no "Host:" header and the HTTP version is not at least
1.1, return a 505 instead ("Wrong HTTP protocol version") since your setup
requires a host header to determine the virtual host.
Swifty
2012-07-02 06:36:09 UTC
Permalink
Post by Jim
Since you are using virtual hosts, you just need to add one. The first
virtual host in your config becomes the default.
You have to be careful with the concept of "first" virtual host.

Often, virtual hosts are defined one per file, and the files are then
included with a wildcard Include directive.

So, your setup could be working perfectly, including the default
virtualhost that you want. Then you make some innocuous change, and
the Include statement now picks a different (i.e. wrong) virtualhost
definition file as the first virtualhost.

I speak from experience here. I now ensure that the first virtualhost
always comes from something which cannot change.
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Lewis
2012-07-02 08:02:46 UTC
Permalink
Post by Swifty
Post by Jim
Since you are using virtual hosts, you just need to add one. The first
virtual host in your config becomes the default.
You have to be careful with the concept of "first" virtual host.
Often, virtual hosts are defined one per file, and the files are then
included with a wildcard Include directive.
So, your setup could be working perfectly, including the default
virtualhost that you want. Then you make some innocuous change, and
the Include statement now picks a different (i.e. wrong) virtualhost
definition file as the first virtualhost.
I speak from experience here. I now ensure that the first virtualhost
always comes from something which cannot change.
I always define the first virtual host in the httpd.conf file before the
includes.
--
Hello Diane, I'm Bucky Goldstein
D. Stussy
2012-07-02 20:12:53 UTC
Permalink
Post by Jim
Since you are using virtual hosts, you just need to add one. The first
virtual host in your config becomes the default.
You have to be careful with the concept of "first" virtual host.

Often, virtual hosts are defined one per file, and the files are then
included with a wildcard Include directive.

So, your setup could be working perfectly, including the default
virtualhost that you want. Then you make some innocuous change, and
the Include statement now picks a different (i.e. wrong) virtualhost
definition file as the first virtualhost.

I speak from experience here. I now ensure that the first virtualhost
always comes from something which cannot change.
===================

That won't happen if it's defined in the MAIN configuration file before any
included file.
Swifty
2012-07-03 19:38:10 UTC
Permalink
On Mon, 2 Jul 2012 13:12:53 -0700, "D. Stussy"
Post by D. Stussy
That won't happen if it's defined in the MAIN configuration file before any
included file.
That's my definition of "something which cannot change" (when you're
not expecting it). :-)
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Lewis
2012-07-03 22:54:23 UTC
Permalink
Post by Swifty
On Mon, 2 Jul 2012 13:12:53 -0700, "D. Stussy"
Post by D. Stussy
That won't happen if it's defined in the MAIN configuration file before any
included file.
That's my definition of "something which cannot change" (when you're
not expecting it). :-)
As long as you don't move your includes before the virtualhost def block/
--
Friction can be a real drag.
Loading...