gpt4 book ai didi

apache - 在 Debian 上启用 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 13:02:38 25 4
gpt4 key购买 nike

我想在我的 Debian/Apache 和 Letsencrypt(通过 Certbot)上启用 SLL。

在 ports.conf 上,端口 80 和 443 都在监听:

Listen 80

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

启用 SSL:

> a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled

我的 VirtualHosts 配置如下:我的主机.conf

    <VirtualHost XX.XX.XX.XX:80>
ServerName www.myhost.com
ServerAlias myhost.com
Redirect / https://www.myhost.com
DocumentRoot /home/myhost/www/public/
CustomLog /var/log/apache2/myhost.com-access.log combined
ErrorLog /var/log/apache2/lmyhost.com-error.log
LogLevel warn
<Directory "/home/myhost/www/public/">
Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

myhost.com-le-ssl.conf:

<IfModule mod_ssl.c>
<VirtualHost XX.XX.XX.XX:443>
ServerName www.myhost.com
ServerAlias myhost.com
# Redirect / https://www.myhost.com
DocumentRoot /home/myhost/www/public/
CustomLog /var/log/apache2/myhost.com-access.log combined
ErrorLog /var/log/apache2/myhost.com-error.log
LogLevel warn
<Directory "/home/myhost/www/public/">
Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/letsencrypt/live/www.myhost.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.myhost.com-0001/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

当我尝试到达 http:///www.myhost.com:443 时, 有用。但是用 https:///www.myhost.com我在 Chrome 上遇到错误:

ERR_SSL_PROTOCOL_ERROR

在我的服务器上,当我检查时:

openssl s_client -crlf -debug -connect www.myhost.com:443 -status -servername www.myhost.com

我明白了:

...
124222757861008:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:782:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 323 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1494247901
Timeout : 300 (sec)
Verify return code: 0 (ok)

最后,在我的 Apache 错误日志中,我可以看到:

[Sun May 07 20:06:53.419500 2017] [core:debug] [pid 18433] protocol.c(1275): [client xx.xx.xx.xx:52254] AH00566: request failed: malformed request line

简而言之,启用了 SSL,端口是正确的,当我通过其 hosts:port 调用 Apache 时,Apache 可以通过。但是,这个端口不能调用我的证书并通过 https 打开我的主机。就好像 SSL 被禁用了...!

你能给我一些解决这个问题的方法吗?感谢大家!

最佳答案

我遇到了和你一样的问题 this是我解决它的方法,但 tl;dr 是:

  1. 虚拟主机配置文件必须以 .conf 结尾
  2. 你必须把它放在sites-available目录下,然后
  3. 您必须运行 a2ensite 才能启用该网站。

关于apache - 在 Debian 上启用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43848299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com