SSL 导致 Apache 崩溃(加载失败)

SSL 导致 Apache 崩溃(加载失败)

当尝试在 Apache2(Ubuntu 17)上使用我的 SSL 时,它似乎破坏了 Apache。

控制台错误

    ● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Thu 2018-05-03 11:52:21 AEST; 2h 4min ago
  Process: 3366 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
      CPU: 85ms

May 03 11:52:20 FRAFFEL_MEDIA systemd[1]: Starting The Apache HTTP Server...
May 03 11:52:21 FRAFFEL_MEDIA apachectl[3366]: AH00558: apache2: Could not reliably determine the server's fully qualifi
May 03 11:52:21 FRAFFEL_MEDIA apachectl[3366]: Action 'start' failed.
May 03 11:52:21 FRAFFEL_MEDIA apachectl[3366]: The Apache error log may have more information.
May 03 11:52:21 FRAFFEL_MEDIA systemd[1]: apache2.service: Control process exited, code=exited status=1
May 03 11:52:21 FRAFFEL_MEDIA systemd[1]: Failed to start The Apache HTTP Server.
May 03 11:52:21 FRAFFEL_MEDIA systemd[1]: apache2.service: Unit entered failed state.
May 03 11:52:21 FRAFFEL_MEDIA systemd[1]: apache2.service: Failed with result 'exit-code'.

在 /var/log/apache2/error_log 中:

[Thu May 03 06:25:01.830302 2018] [mpm_prefork:notice] [pid 4511] AH00163: Apache/2.4.25 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Thu May 03 06:25:01.830372 2018] [core:notice] [pid 4511] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 03 08:03:44.188546 2018] [:error] [pid 13778] [client 95.213.177.126:63358] script '/var/www/404/azenv.php' not found or unable to stat, referer: https://proxyradar.com/
[Thu May 03 11:29:21.335601 2018] [mpm_prefork:notice] [pid 4511] AH00171: Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using fe80::f03c:91ff:fea7:2ab8. Set the 'ServerName' directive globally to suppress this message
[Thu May 03 11:29:21.424519 2018] [ssl:warn] [pid 4511] AH01909: fe80::f03c:91ff:fea7:2ab8:80:0 server certificate does NOT include an ID which matches the server name
[Thu May 03 11:29:21.424615 2018] [ssl:emerg] [pid 4511] AH02569: Illegal attempt to re-initialise SSL for server (SSLEngine On should go in the VirtualHost, not in global scope.)
[Thu May 03 11:29:21.424621 2018] [:emerg] [pid 4511] AH00020: Configuration Failed, exiting
[Thu May 03 11:36:17.850289 2018] [ssl:warn] [pid 3415] AH01909: 2600:3c01::f03c:91ff:fea7:2ab8:80:0 server certificate does NOT include an ID which matches the server name
[Thu May 03 11:36:17.851117 2018] [ssl:emerg] [pid 3415] AH02569: Illegal attempt to re-initialise SSL for server (SSLEngine On should go in the VirtualHost, not in global scope.)
AH00016: Configuration Failed
[Thu May 03 11:52:21.316911 2018] [ssl:warn] [pid 3393] AH01909: fe80::f03c:91ff:fea7:2ab8:80:0 server certificate does NOT include an ID which matches the server name
[Thu May 03 11:52:21.323098 2018] [ssl:emerg] [pid 3393] AH02569: Illegal attempt to re-initialise SSL for server (SSLEngine On should go in the VirtualHost, not in global scope.)
AH00016: Configuration Failed

我不确定这是怎么回事,因为它仅在可用站点配置中使用 SSL 时才会发生:

<virtualhost *:443> 
ServerName fraffel.tech 
DocumentRoot /var/www/fraffeltech
</virtualhost>

SSLEngine on 
SSLCertificateFile /etc/ssl/fraffel_tech.crt 
SSLCertificateKeyFile /etc/ssl/private/fraffel.tech.key 
SSLCertificateChainFile /etc/ssl/fraffel_tech.ca-bundle 

SSL 文件位于这些目录中,但我不确定它有什么用处,并且 SSL 模块已启用...

答案1

将您的虚拟主机更改为

<VirtualHost *:443> 
    ServerName fraffel.tech 
    DocumentRoot /var/www/fraffeltech

    SSLEngine on 
    SSLCertificateFile /etc/ssl/fraffel_tech.crt 
    SSLCertificateKeyFile /etc/ssl/private/fraffel.tech.key 
    SSLCertificateChainFile /etc/ssl/fraffel_tech.ca-bundle 
</VirtualHost>

提示是这样的:

[2018 年 5 月 3 日星期四 11:36:17.851117] [ssl:emerg] [pid 3415] AH02569:非法尝试重新初始化服务器的 SSL(SSLEngine On 应该进入 VirtualHost,而不是全局范围。)


此外,还有一条警告信息告诉您:

无法可靠地确定服务器的完全限定域名,使用 fe80::f03c:91ff... 全局设置“ServerName”指令以隐藏此消息

全局设置“ServerName”指令以隐藏此消息意味着你应该在标签ServerName之外有一个指令<VirtualHost>。它可以是你的主域名,也可以只是本地主机

ServerName fraffel.tech 

<VirtualHost *:443> 
    ServerName fraffel.tech 
    DocumentRoot /var/www/fraffeltech

    #...
</VirtualHost>

相关内容