Hi Maxim. Thanks for your comments. On Sat, Nov 24, 2018 at 4:35 AM Maxim Dounin <mdou...@mdounin.ru> wrote: > No, thank you. This change makes nginx startup unconditionally > dependant on the DNS availability. This is not something we are > going to accept.
That's reasonable. I based this behaviour off `hostname -f` which also uses `gethostbyname` for resolving the FQDN. Note, on most systems this doesn't trigger an actual DNS lookup provided that hosts canonical name (usually the FQDN) is configured in `/etc/hosts` (See paragraph 5 of THE FQDN <https://manpages.debian.org/testing/hostname/hostname.1.en.html>). On some systems `gethostent` can be used to explicitly walk `/etc/hosts`, but behaviour is so inconsistent I would avoid it. How would you feel about trying to resolve the FQDN at nginx startup and, if unavailable falling back to `$hostname`? This matches the behaviour of other languages (e.g. Python's `socket.getfqdn()` <https://docs.python.org/3/library/socket.html#socket.getfqdn>). I could also make this a runtime evaluation, but it would be nice to only evaluate once as it would often be used in hot paths like logging and tracing. > Also, the $hostname variable is expected to be FQDN on systems > participating in the DNS. If it's not FQDN in your case, you may > want to consider reconfiguring your system. See > http://mailman.nginx.org/pipermail/nginx/2017-February/052885.html > for a previous discussion on the topic. Thank you for the pointer to the previous discussion. Doing some investigation I've found several contrary recommendations: https://www.gnu.org/software/libc/manual/html_node/Host-Identification.html : Function: int gethostname (char *name, size_t size) ... : If the system participates in the DNS, this is the FQDN (see : above). https://manpages.debian.org/testing/hostname/hostname.1.en.html : The recommended method of setting the FQDN is to make the hostname be an alias : for the fully qualified name using /etc/hosts, DNS, or NIS. For example, if the : hostname was "ursula", one might have a line in /etc/hosts which reads : : 127.0.1.1 ursula.example.com ursula The Linux programming interface. Kerrisk, M. (2010). §12.2 (p. 299) <https://books.google.com/books?id=Ps2SH727eCIC&lpg=PR7&ots=kMFex6wMt7&lr&pg=PA229#v=onepage&q&f=false> : Often, this name is something like the hostname prefix from the system’s DNS : domain name. Advanced programming in the UNIX environment. Stevens, W. R., & Rago, S. A. (2013). §6.9 (p. 172) <https://books.google.com/books?id=kCTMFpEcIOwC&lpg=PR9&ots=zwHyTPTvlB&lr&pg=PA188#v=onepage&q&f=false> : Historically, BSD-derived systems provide the `gethostname` function to return : only the name of the host. : ... : If the host is connected to a TCP/IP network, the host name is normally the : fully qualified domain name of the host. Linux in particular seems to have interpreted `gethostname` as returning a DNS label (maximum of 63 characters) rather than a full DNS name (up to 213 characters). Thus it's impossible to represent certain DNS names as the system hostname. _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel