The ServerName directive sets the
request scheme, hostname and port that the server uses to identify itself.
ServerName is used (possibly
in conjunction with ServerAlias ) to uniquely
identify a virtual host, when using name-based virtual hosts.
Additionally, this is used when
creating self-referential redirection URLs when
UseCanonicalName is set to a non-default
value.
For example, if the name of the
machine hosting the web server is simple.example.com ,
but the machine also has the DNS alias www.example.com
and you wish the web server to be so identified, the following
directive should be used:
ServerName www.example.com
The ServerName directive
may appear anywhere within the definition of a server. However,
each appearance overrides the previous appearance (within that
server).
If no ServerName is specified, the
server attempts to deduce the client visible hostname by first asking
the operating system for the system hostname, and if that fails,
performing a reverse lookup on an IP address present on the system.
If no port is specified in the
ServerName , then the server will use the
port from the incoming request. For optimal reliability and
predictability, you should specify an explicit hostname and port
using the ServerName directive.
If you are using name-based virtual hosts,
the ServerName inside a
<VirtualHost>
section specifies what hostname must appear in the request's
Host: header to match this virtual host.
Sometimes, the server runs behind a device that processes SSL,
such as a reverse proxy, load balancer or SSL offload
appliance. When this is the case, specify the
https:// scheme and the port number to which the
clients connect in the ServerName directive
to make sure that the server generates the correct
self-referential URLs.
See the description of the
UseCanonicalName and
UseCanonicalPhysicalPort directives for
settings which determine whether self-referential URLs (e.g., by the
mod_dir module) will refer to the
specified port, or to the port number given in the client's request.
Failure to set ServerName to a name that
your server can resolve to an IP address will result in a startup
warning. httpd will then use whatever hostname it can
determine, using the system's hostname command. This
will almost never be the hostname you actually want.
httpd: Could not reliably determine the server's fully qualified domain name, using rocinante.local for ServerName
See also
- Issues Regarding DNS and
Apache HTTP Server
- Apache HTTP Server virtual host
documentation
-
UseCanonicalName
-
UseCanonicalPhysicalPort
-
ServerAlias