From ab98337579ea62de3221a4ca948dc869716b5ab1 Mon Sep 17 00:00:00 2001
From: Daniel Gruno
Date: Fri, 4 May 2012 14:44:34 +0000
Subject: [PATCH] Backporting syntax highlighting for vhosts/
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1334000 13f79535-47bb-0310-9956-ffa450edef68
---
docs/manual/vhosts/examples.xml | 509 +++++++++++++-----------------
docs/manual/vhosts/fd-limits.xml | 6 +-
docs/manual/vhosts/ip-based.xml | 38 +--
docs/manual/vhosts/mass.xml | 150 ++++-----
docs/manual/vhosts/name-based.xml | 35 +-
5 files changed, 319 insertions(+), 419 deletions(-)
diff --git a/docs/manual/vhosts/examples.xml b/docs/manual/vhosts/examples.xml
index 0d96e98454..86f99f07bf 100644
--- a/docs/manual/vhosts/examples.xml
+++ b/docs/manual/vhosts/examples.xml
@@ -53,33 +53,23 @@
hosts
entries.
-
- Server configuration
-
- # Ensure that Apache listens on port 80
- Listen 80
-
-
- <VirtualHost *:80>
-
- DocumentRoot /www/example1
- ServerName www.example.com
-
- # Other directives here
-
-
- </VirtualHost>
-
- <VirtualHost *:80>
-
- DocumentRoot /www/example2
- ServerName www.example.org
-
- # Other directives here
-
-
- </VirtualHost>
-
+
+# Ensure that Apache listens on port 80
+Listen 80
+<VirtualHost *:80>
+ DocumentRoot /www/example1
+ ServerName www.example.com
+
+ # Other directives here
+</VirtualHost>
+
+<VirtualHost *:80>
+ DocumentRoot /www/example2
+ ServerName www.example.org
+
+ # Other directives here
+</VirtualHost>
+
The asterisks match all addresses, so the main server serves no
requests. Due to the fact that the virtual host with
@@ -126,35 +116,27 @@
will serve the "main" server, server.example.com
and on the
other (172.20.30.50
), we will serve two or more virtual hosts.
-
- Server configuration
-
- Listen 80
-
- # This is the "main" server running on 172.20.30.40
- ServerName server.example.com
- DocumentRoot /www/mainserver
-
- <VirtualHost 172.20.30.50>
-
- DocumentRoot /www/example1
- ServerName www.example.com
-
- # Other directives here ...
-
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.50>
-
- DocumentRoot /www/example2
- ServerName www.example.org
-
- # Other directives here ...
-
-
- </VirtualHost>
-
+
+Listen 80
+
+# This is the "main" server running on 172.20.30.40
+ServerName server.example.com
+DocumentRoot /www/mainserver
+
+<VirtualHost 172.20.30.50>
+ DocumentRoot /www/example1
+ ServerName www.example.com
+
+ # Other directives here ...
+</VirtualHost>
+
+<VirtualHost 172.20.30.50>
+ DocumentRoot /www/example2
+ ServerName www.example.org
+
+ # Other directives here ...
+</VirtualHost>
+
Any request to an address other than 172.20.30.50
will be
served from the main server. A request to 172.20.30.50
with an
@@ -179,18 +161,13 @@
with the same content, with just one VirtualHost
section.
-
- Server configuration
-
-
- <VirtualHost 192.168.1.1 172.20.30.40>
-
- DocumentRoot /www/server1
- ServerName server.example.com
- ServerAlias server
-
- </VirtualHost>
-
+
+<VirtualHost 192.168.1.1 172.20.30.40>
+ DocumentRoot /www/server1
+ ServerName server.example.com
+ ServerAlias server
+</VirtualHost>
+
Now requests from both networks will be served from the same
VirtualHost
.
@@ -216,40 +193,30 @@
takes place after the best matching IP address and port combination
is determined.
-
- Server configuration
-
- Listen 80
- Listen 8080
-
- <VirtualHost 172.20.30.40:80>
-
- ServerName www.example.com
- DocumentRoot /www/domain-80
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40:8080>
-
- ServerName www.example.com
- DocumentRoot /www/domain-8080
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40:80>
-
- ServerName www.example.org
- DocumentRoot /www/otherdomain-80
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40:8080>
-
- ServerName www.example.org
- DocumentRoot /www/otherdomain-8080
-
- </VirtualHost>
-
+
+Listen 80
+Listen 8080
+
+<VirtualHost 172.20.30.40:80>
+ ServerName www.example.com
+ DocumentRoot /www/domain-80
+</VirtualHost>
+
+<VirtualHost 172.20.30.40:8080>
+ ServerName www.example.com
+ DocumentRoot /www/domain-8080
+</VirtualHost>
+
+<VirtualHost 172.20.30.40:80>
+ ServerName www.example.org
+ DocumentRoot /www/otherdomain-80
+</VirtualHost>
+
+<VirtualHost 172.20.30.40:8080>
+ ServerName www.example.org
+ DocumentRoot /www/otherdomain-8080
+</VirtualHost>
+
@@ -260,25 +227,19 @@
www.example.com
and www.example.org
respectively.
-
- Server configuration
-
- Listen 80
-
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/example1
- ServerName www.example.com
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.50>
-
- DocumentRoot /www/example2
- ServerName www.example.org
-
- </VirtualHost>
-
+
+Listen 80
+
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/example1
+ ServerName www.example.com
+</VirtualHost>
+
+<VirtualHost 172.20.30.50>
+ DocumentRoot /www/example2
+ ServerName www.example.org
+</VirtualHost>
+
Requests for any address not specified in one of the
<VirtualHost>
directives (such as
@@ -296,42 +257,32 @@
respectively. In each case, we want to run hosts on ports 80 and
8080.
-
- Server configuration
-
- Listen 172.20.30.40:80
- Listen 172.20.30.40:8080
- Listen 172.20.30.50:80
- Listen 172.20.30.50:8080
-
- <VirtualHost 172.20.30.40:80>
-
- DocumentRoot /www/example1-80
- ServerName www.example.com
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40:8080>
-
- DocumentRoot /www/example1-8080
- ServerName www.example.com
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.50:80>
-
- DocumentRoot /www/example2-80
- ServerName www.example.org
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.50:8080>
-
- DocumentRoot /www/example2-8080
- ServerName www.example.org
-
- </VirtualHost>
-
+
+Listen 172.20.30.40:80
+Listen 172.20.30.40:8080
+Listen 172.20.30.50:80
+Listen 172.20.30.50:8080
+
+<VirtualHost 172.20.30.40:80>
+ DocumentRoot /www/example1-80
+ ServerName www.example.com
+</VirtualHost>
+
+<VirtualHost 172.20.30.40:8080>
+ DocumentRoot /www/example1-8080
+ ServerName www.example.com
+</VirtualHost>
+
+<VirtualHost 172.20.30.50:80>
+ DocumentRoot /www/example2-80
+ ServerName www.example.org
+</VirtualHost>
+
+<VirtualHost 172.20.30.50:8080>
+ DocumentRoot /www/example2-8080
+ ServerName www.example.org
+</VirtualHost>
+
@@ -341,46 +292,34 @@
Any address mentioned in the argument to a virtualhost that never
appears in another virtual host is a strictly IP-based virtual host.
-
- Server configuration
-
- Listen 80
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/example1
- ServerName www.example.com
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/example2
- ServerName www.example.org
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/example3
- ServerName www.example.net
-
- </VirtualHost>
-
- # IP-based
- <VirtualHost 172.20.30.50>
-
- DocumentRoot /www/example4
- ServerName www.example.edu
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.60>
-
- DocumentRoot /www/example5
- ServerName www.example.gov
-
- </VirtualHost>
-
+
+Listen 80
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/example1
+ ServerName www.example.com
+</VirtualHost>
+
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/example2
+ ServerName www.example.org
+</VirtualHost>
+
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/example3
+ ServerName www.example.net
+</VirtualHost>
+
+# IP-based
+<VirtualHost 172.20.30.50>
+ DocumentRoot /www/example4
+ ServerName www.example.edu
+</VirtualHost>
+
+<VirtualHost 172.20.30.60>
+ DocumentRoot /www/example5
+ ServerName www.example.gov
+</VirtualHost>
+
@@ -395,14 +334,14 @@
used so that the desired hostname is passed through, in case we are
proxying multiple hostnames to a single machine.
-
- <VirtualHost *:*>
- ProxyPreserveHost On
- ProxyPass / http://192.168.111.2/
- ProxyPassReverse / http://192.168.111.2/
- ServerName hostname.example.com
- </VirtualHost>
-
+
+<VirtualHost *:*>
+ ProxyPreserveHost On
+ ProxyPass / http://192.168.111.2/
+ ProxyPassReverse / http://192.168.111.2/
+ ServerName hostname.example.com
+</VirtualHost>
+
@@ -416,15 +355,11 @@
port, i.e., an address/port combination that is not used for
any other virtual host.
-
- Server configuration
-
- <VirtualHost _default_:*>
-
- DocumentRoot /www/default
-
- </VirtualHost>
-
+
+<VirtualHost _default_:*>
+ DocumentRoot /www/default
+</VirtualHost>
+
Using such a default vhost with a wildcard port effectively prevents
any request going to the main server.
@@ -446,23 +381,17 @@
Same as setup 1, but the server listens on several ports and we want
to use a second _default_
vhost for port 80.
-
- Server configuration
-
- <VirtualHost _default_:80>
-
- DocumentRoot /www/default80
- # ...
-
- </VirtualHost>
-
- <VirtualHost _default_:*>
-
- DocumentRoot /www/default
- # ...
-
- </VirtualHost>
-
+
+<VirtualHost _default_:80>
+ DocumentRoot /www/default80
+ # ...
+</VirtualHost>
+
+<VirtualHost _default_:*>
+ DocumentRoot /www/default
+ # ...
+</VirtualHost>
+
The default vhost for port 80 (which must appear before any
default vhost with a wildcard port) catches all requests that were sent
@@ -476,14 +405,12 @@
We want to have a default vhost for port 80, but no other default
vhosts.
-
- Server configuration
-
- <VirtualHost _default_:80>
- DocumentRoot /www/default
- ...
- </VirtualHost>
-
+
+<VirtualHost _default_:80>
+DocumentRoot /www/default
+...
+</VirtualHost>
+
A request to an unspecified address on port 80 is served from the
default vhost. Any other request to an unspecified address and port is
@@ -511,30 +438,24 @@
(172.20.30.50
) to the VirtualHost
directive.
-
- Server configuration
-
- Listen 80
- ServerName www.example.com
- DocumentRoot /www/example1
-
- <VirtualHost 172.20.30.40 172.20.30.50>
-
- DocumentRoot /www/example2
- ServerName www.example.org
- # ...
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/example3
- ServerName www.example.net
- ServerAlias *.example.net
- # ...
-
- </VirtualHost>
-
+
+Listen 80
+ServerName www.example.com
+DocumentRoot /www/example1
+
+<VirtualHost 172.20.30.40 172.20.30.50>
+ DocumentRoot /www/example2
+ ServerName www.example.org
+ # ...
+</VirtualHost>
+
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/example3
+ ServerName www.example.net
+ ServerAlias *.example.net
+ # ...
+</VirtualHost>
+
The vhost can now be accessed through the new address (as an
IP-based vhost) and through the old address (as a name-based
@@ -554,41 +475,33 @@
containing links with an URL prefix to the name-based virtual
hosts.
-
- Server configuration
-
- <VirtualHost 172.20.30.40>
-
- # primary vhost
- DocumentRoot /www/subdomain
- RewriteEngine On
- RewriteRule . /www/subdomain/index.html
- # ...
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40>
- DocumentRoot /www/subdomain/sub1
-
- ServerName www.sub1.domain.tld
- ServerPath /sub1/
- RewriteEngine On
- RewriteRule ^(/sub1/.*) /www/subdomain$1
- # ...
-
- </VirtualHost>
-
- <VirtualHost 172.20.30.40>
-
- DocumentRoot /www/subdomain/sub2
- ServerName www.sub2.domain.tld
- ServerPath /sub2/
- RewriteEngine On
- RewriteRule ^(/sub2/.*) /www/subdomain$1
- # ...
-
- </VirtualHost>
-
+
+<VirtualHost 172.20.30.40>
+ # primary vhost
+ DocumentRoot /www/subdomain
+ RewriteEngine On
+ RewriteRule . /www/subdomain/index.html
+ # ...
+</VirtualHost>
+
+<VirtualHost 172.20.30.40>
+DocumentRoot /www/subdomain/sub1
+ ServerName www.sub1.domain.tld
+ ServerPath /sub1/
+ RewriteEngine On
+ RewriteRule ^(/sub1/.*) /www/subdomain$1
+ # ...
+</VirtualHost>
+
+<VirtualHost 172.20.30.40>
+ DocumentRoot /www/subdomain/sub2
+ ServerName www.sub2.domain.tld
+ ServerPath /sub2/
+ RewriteEngine On
+ RewriteRule ^(/sub2/.*) /www/subdomain$1
+ # ...
+</VirtualHost>
+
Due to the ServerPath
directive a request to the URL
diff --git a/docs/manual/vhosts/fd-limits.xml b/docs/manual/vhosts/fd-limits.xml
index 2c08d07956..cd9802eb6e 100644
--- a/docs/manual/vhosts/fd-limits.xml
+++ b/docs/manual/vhosts/fd-limits.xml
@@ -91,10 +91,10 @@ LogFormat
directive, and the %v
variable. Add this to the beginning
of your log format string:
-
-LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
+
+LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
CustomLog logs/multiple_vhost_log vhost
-
+
This will create a log file in the common log format, but with the
canonical virtual host (whatever appears in the
diff --git a/docs/manual/vhosts/ip-based.xml b/docs/manual/vhosts/ip-based.xml
index 37cb7727f4..69c323b3bb 100644
--- a/docs/manual/vhosts/ip-based.xml
+++ b/docs/manual/vhosts/ip-based.xml
@@ -108,9 +108,9 @@ Virtual Hosts to help you decide.
configuration file to select which IP address (or virtual host)
that daemon services. e.g.
-
+
Listen 192.0.2.100:80
-
+
It is recommended that you use an IP address instead of a
hostname (see DNS caveats).
@@ -133,23 +133,23 @@ Virtual Hosts to help you decide.
configuration directives to different values for each virtual
host. e.g.
-
- <VirtualHost 172.20.30.40:80>
- ServerAdmin webmaster@www1.example.com
- DocumentRoot /www/vhosts/www1
- ServerName www1.example.com
- ErrorLog /www/logs/www1/error_log
- CustomLog /www/logs/www1/access_log combined
- </VirtualHost>
-
- <VirtualHost 172.20.30.50:80>
- ServerAdmin webmaster@www2.example.org
- DocumentRoot /www/vhosts/www2
- ServerName www2.example.org
- ErrorLog /www/logs/www2/error_log
- CustomLog /www/logs/www2/access_log combined
- </VirtualHost>
-
+
+<VirtualHost 172.20.30.40:80>
+ ServerAdmin webmaster@www1.example.com
+ DocumentRoot /www/vhosts/www1
+ ServerName www1.example.com
+ ErrorLog /www/logs/www1/error_log
+ CustomLog /www/logs/www1/access_log combined
+</VirtualHost>
+
+<VirtualHost 172.20.30.50:80>
+ ServerAdmin webmaster@www2.example.org
+ DocumentRoot /www/vhosts/www2
+ ServerName www2.example.org
+ ErrorLog /www/logs/www2/error_log
+ CustomLog /www/logs/www2/access_log combined
+</VirtualHost>
+
It is recommended that you use an IP address instead of a
hostname in the <VirtualHost> directive
diff --git a/docs/manual/vhosts/mass.xml b/docs/manual/vhosts/mass.xml
index 3df4e2531c..3a5afcb436 100644
--- a/docs/manual/vhosts/mass.xml
+++ b/docs/manual/vhosts/mass.xml
@@ -41,8 +41,7 @@
<VirtualHost>
sections that are
substantially the same, for example:
-
-
+
<VirtualHost 111.22.33.44>
ServerName customer-1.example.com
DocumentRoot /www/hosts/customer-1.example.com/docs
@@ -60,8 +59,7 @@
DocumentRoot /www/hosts/customer-N.example.com/docs
ScriptAlias /cgi-bin/ /www/hosts/customer-N.example.com/cgi-bin
</VirtualHost>
-
-
+
We wish to replace these multiple
<VirtualHost>
blocks with a mechanism
@@ -149,19 +147,19 @@ mod_vhost_alias
href="#motivation">Motivation section above
using mod_vhost_alias.
-
-# get the server name from the Host: header
-UseCanonicalName Off
-
-# this log format can be split per-virtual-host based on the first field
-# using the split-logfile utility.
-LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
-
-# include the server name in the filenames used to satisfy requests
-VirtualDocumentRoot /www/hosts/%0/docs
+
+# get the server name from the Host: header
+UseCanonicalName Off
+
+# this log format can be split per-virtual-host based on the first field
+# using the split-logfile utility.
+LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
+CustomLog logs/access_log vcommon
+
+# include the server name in the filenames used to satisfy requests
+VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias /www/hosts/%0/cgi-bin
-
+
This configuration can be changed into an IP-based virtual
hosting solution by just turning UseCanonicalName
@@ -186,18 +184,18 @@ examples.
/home/user/www
. It uses a single cgi-bin
directory instead of one per virtual host.
-
-UseCanonicalName Off
-
-LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
-
-# include part of the server name in the filenames
-VirtualDocumentRoot /home/%2/www
-
-# single cgi-bin directory
-ScriptAlias /cgi-bin/ /www/std-cgi/
-
+
+UseCanonicalName Off
+
+LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
+CustomLog logs/access_log vcommon
+
+# include part of the server name in the filenames
+VirtualDocumentRoot /home/%2/www
+
+# single cgi-bin directory
+ScriptAlias /cgi-bin/ /www/std-cgi/
+
There are examples of more complicated
VirtualDocumentRoot
settings in the
@@ -217,47 +215,39 @@ ScriptAlias /cgi-bin/ /www/std-cgi/
<VirtualHost>
configuration sections, as shown
below.
-
-UseCanonicalName Off
-
-LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-
-<Directory /www/commercial>
-
- Options FollowSymLinks
- AllowOverride All
-
-</Directory>
-
-<Directory /www/homepages>
-
- Options FollowSymLinks
- AllowOverride None
-
-</Directory>
-
-<VirtualHost 111.22.33.44>
-
- ServerName www.commercial.example.com
-
- CustomLog logs/access_log.commercial vcommon
-
- VirtualDocumentRoot /www/commercial/%0/docs
- VirtualScriptAlias /www/commercial/%0/cgi-bin
-
-</VirtualHost>
-
-<VirtualHost 111.22.33.45>
-
- ServerName www.homepages.example.com
-
- CustomLog logs/access_log.homepages vcommon
-
- VirtualDocumentRoot /www/homepages/%0/docs
- ScriptAlias /cgi-bin/ /www/std-cgi/
-
+
+UseCanonicalName Off
+
+LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
+
+<Directory /www/commercial>
+ Options FollowSymLinks
+ AllowOverride All
+</Directory>
+
+<Directory /www/homepages>
+ Options FollowSymLinks
+ AllowOverride None
+</Directory>
+
+<VirtualHost 111.22.33.44>
+ ServerName www.commercial.example.com
+
+ CustomLog logs/access_log.commercial vcommon
+
+ VirtualDocumentRoot /www/commercial/%0/docs
+ VirtualScriptAlias /www/commercial/%0/cgi-bin
</VirtualHost>
-
+
+<VirtualHost 111.22.33.45>
+ ServerName www.homepages.example.com
+
+ CustomLog logs/access_log.homepages vcommon
+
+ VirtualDocumentRoot /www/homepages/%0/docs
+ ScriptAlias /cgi-bin/ /www/std-cgi/
+</VirtualHost>
+
Note
@@ -282,18 +272,18 @@ LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
negating the need for a DNS lookup. Logging will also have to be adjusted
to fit this system.
-
-# get the server name from the reverse DNS of the IP address
-UseCanonicalName DNS
-
-# include the IP address in the logs so they may be split
-LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
-
-# include the IP address in the filenames
-VirtualDocumentRootIP /www/hosts/%0/docs
-VirtualScriptAliasIP /www/hosts/%0/cgi-bin
-
+
+# get the server name from the reverse DNS of the IP address
+UseCanonicalName DNS
+
+# include the IP address in the logs so they may be split
+LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
+CustomLog logs/access_log vcommon
+
+# include the IP address in the filenames
+VirtualDocumentRootIP /www/hosts/%0/docs
+VirtualScriptAliasIP /www/hosts/%0/cgi-bin
+
diff --git a/docs/manual/vhosts/name-based.xml b/docs/manual/vhosts/name-based.xml
index 63ae0efab2..003efec6e8 100644
--- a/docs/manual/vhosts/name-based.xml
+++ b/docs/manual/vhosts/name-based.xml
@@ -127,22 +127,19 @@
other.example.com
, which points at the same IP address.
Then you simply add the following to httpd.conf
:
-
- <VirtualHost *:80>
-
- # This first-listed virtual host is also the default for *:80
- ServerName www.example.com
- ServerAlias example.com
- DocumentRoot /www/domain
-
- </VirtualHost>
-
- <VirtualHost *:80>
- ServerName other.example.com
- DocumentRoot /www/otherdomain
-
- </VirtualHost>
-
+
+<VirtualHost *:80>
+ # This first-listed virtual host is also the default for *:80
+ ServerName www.example.com
+ ServerAlias example.com
+ DocumentRoot /www/domain
+</VirtualHost>
+
+<VirtualHost *:80>
+ServerName other.example.com
+ DocumentRoot /www/otherdomain
+</VirtualHost>
+
You can alternatively specify an explicit IP address in place of the
*
in
-
+
ServerAlias example.com *.example.com
-
+
then requests for all hosts in the example.com
domain will
be served by the www.example.com
virtual host. The wildcard
@@ -172,7 +169,7 @@
address associated with your server.
Name-based virtual hosts for the best-matching set of virtualhosts are processsed
+ type="section" module="core">virtualhost
s are processed
in the order they appear in the configuration. The first matching ServerName or ServerAlias is used, with no different precedence for wildcards
--
2.40.0