that directive from the default config.
This could use some review because it has potential security
implications. In particular, it could cause cross-site scripting
vulnerabilities if people rely on SERVER_NAME without validating
it. But we have been running with this in our default config file
for a while, and it vastly reduces the confusion that comes
from people setting ServerName incorrectly.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/simple-conf@160595
13f79535-47bb-0310-9956-
ffa450edef68
#
KeepAliveTimeout 15
+#
+# UseCanonicalName: Determines how Apache constructs self-referencing
+# URLs and the SERVER_NAME and SERVER_PORT variables.
+# When set "Off", Apache will use the Hostname and Port supplied
+# by the client. When set "On", Apache will use the value of the
+# ServerName directive.
+#
+UseCanonicalName Off
+
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
-# You will have to access it by its address anyway, and this will make
-# redirections work in a sensible way.
#
#ServerName www.example.com:80
-#
-# UseCanonicalName: Determines how Apache constructs self-referencing
-# URLs and the SERVER_NAME and SERVER_PORT variables.
-# When set "Off", Apache will use the Hostname and Port supplied
-# by the client. When set "On", Apache will use the value of the
-# ServerName directive.
-#
-UseCanonicalName Off
-
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
<description>Configures how the server determines its own name and
port</description>
<syntax>UseCanonicalName On|Off|DNS</syntax>
-<default>UseCanonicalName On</default>
+<default>UseCanonicalName Off</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context></contextlist>
d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
&core_module);
- if (d->use_canonical_name == USE_CANONICAL_NAME_OFF) {
- return r->hostname ? r->hostname : r->server->server_hostname;
+ if (d->use_canonical_name == USE_CANONICAL_NAME_ON) {
+ return r->server->server_hostname;
}
if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
}
/* default */
- return r->server->server_hostname;
+ return r->hostname ? r->hostname : r->server->server_hostname;
}
/*