Opened 8 years ago
Closed 8 years ago
#1171 closed enhancement (wontfix)
Clarify $server_name variable with regex server_name directive
Reported by: | davidjb | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | documentation | Version: | 1.10.x |
Keywords: | Cc: | ||
uname -a: | N/A | ||
nginx -V: | N/A |
Description
The documentation for $server_name mentions the following:
$server_name name of the server which accepted a request.
When using the server_name
directive with regex and captures (like in the documentation), it was unclear to me without testing what the $server_name
variable would end up being. After looking at the source, I can now see the variable is always the string literal of the matching server_name
.
I'd suggest adding an additional line to the documentation for $server_name
to clarify the expected value of this variable, such as the following:
$server_name
name of the server which accepted a request.
If the server_name directive contains one or more regular expressions, $server_name will be the string literal of the matching regular expression; it is not evaluated in this variable.
The server_name directive documentation explicitly says that the first name specified will be used as the primary name:
It doesn't matter if the name uses wildcards, or regular expressions - the name will be as written in the configuration. And I think it is clear form the
server_name
directive description.Additionally, the suggested text is not technically correct:
$server_name
. It is mean to specify a string form the configuration, in contrast to$host
which is from the client request.Overall, I don't see any improvement in the clarification suggested.