У меня есть vServer с доменом (от strato), работающим на Apache2. У моего единственного работающего сайта есть следующий vHost:
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLCertificateFile /etc/letsencrypt/live/example.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName www.example.de
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>
и следующий apache2ctl -S:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using xxx:xxx:xxx:xxxx::x. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443 is a NameVirtualHost
default server www.example.de (/etc/apache2/sites-enabled/vps.conf:2)
port 443 namevhost www.example.de (/etc/apache2/sites-enabled/vps.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
В конце концов, я прочитал, что у меня не должно быть доступа к моему серверу под www.example.com, потому что я никогда не настраивал свою DNS-запись для соответствия этому поддомену. У меня есть только запись example.de с соответствующими IP-адресами. Но он хочет подключиться к моему серверу под www, поэтому я изменил ServerName на www.example.com. Забавно то, что я могу подключиться к своему серверу под www.example.com И example.com, и ошибки сертификата нет.
Я этого не понимаю, но я хочу понять, потому что меня это беспокоит.
К вашему сведению: на сервере работает owncloud.
Спасибо!
Ключевым моментом здесь является «сервер по умолчанию». У Apache всегда есть «сервер по умолчанию» ... который будет принимать соединения для любого сайта, имя хоста которого не совпадает ни с чем определенным.
В этом случае, как правильно показывают ваши журналы:
default server www.example.de (/etc/apache2/sites-enabled/vps.conf:2)
www.example.de - ваш сайт по умолчанию, и все несоответствующие имена хостов будут отправлены на этот сайт.
Обычно я рекомендую людям настроить стандартный сайт «404» для сайта по умолчанию, чтобы сообщить людям, что они не достигли нужного сайта ... а затем убедиться, что ваши правильные домены определены правильно.