pix*_*sic 32 webserver ssl openssl https apache-httpd
我正在尝试在我的 apache2 网络服务器上设置 SSL,但它似乎根本不起作用。
我已经按照教程使用 openssl 创建证书文件并/etc/apache2/sites-available/default-ssl.conf正确配置。
每次我尝试使用 https 打开我的网站时,由于安全问题,我的浏览器拒绝连接。它说我没有正确配置我的网站。
在我的/var/log/apache2/error.log我收到警告,说我的服务器证书不包含与服务器名称匹配的 ID。
[Mon Apr 10 11:03:24.041813 2017] [mpm_prefork:notice] [pid 1222] AH00169: caught SIGTERM, shutting down
[Mon Apr 10 11:03:30.566578 2017] [ssl:warn] [pid 661] AH01909: 127.0.0.1:443:0 server certificate does NOT include an ID which matches the server name
[Mon Apr 10 11:03:31.579088 2017] [ssl:warn] [pid 1194] AH01909: 127.0.0.1:443:0 server certificate does NOT include an ID which matches the server name
[Mon Apr 10 11:03:31.592958 2017] [mpm_prefork:notice] [pid 1194] AH00163: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2k configured -- resuming normal operations
[Mon Apr 10 11:03:31.593136 2017] [core:notice] [pid 1194] AH00094: Command line: '/usr/sbin/apache2'
Run Code Online (Sandbox Code Playgroud)
你对如何解决这个问题有什么想法吗?致谢!
pix*_*sic 13
好的,我注意到最近这篇文章被经常查看,所以似乎很多人都面临着和我一样的问题。如果是这样,那么这可能会对您有所帮助。
我按照一个简单的分步教程为我的网络服务器创建了 SSL 认证。像很多教程一样,我遵循的教程的结果是使用 OpenSSL 的自签名证书。是的自签名,这就是问题所在。浏览器无法信任服务器,因为它的证书是自己签名的。嗯,我也不会...
证书必须由外部可信赖的证书颁发机构 (CA) 签名。所以我偶然发现了Let's Encrypt,它可以为您完成所有工作,而且设置起来更容易,最好的是:它是完全免费的。
1) 删除您使用 OpenSSL 创建的旧 ssl 证书文件
2) 在 Debian 上打开 backports 以获取 certbot 客户端。你应该知道这会给未完成的软件打开一个漏洞!仅当您知道自己在做什么时才安装软件包。
echo 'deb http://ftp.debian.org/debian jessie-backports main' | sudo tee /etc/apt/sources.list.d/backports.list
Run Code Online (Sandbox Code Playgroud)
3) 更新你的 linux 系统
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
4)安装certbot
sudo apt-get install python-certbot-apache -t jessie-backports
Run Code Online (Sandbox Code Playgroud)
5)设置apache ServerName和ServerAlias
sudo nano /etc/apache2/sites-available/000-default.conf
Run Code Online (Sandbox Code Playgroud)
6)编辑apache配置文件
<VirtualHost *:80>
. . .
ServerName example.com
ServerAlias www.example.com
. . .
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
7) 检查语法是否正确
sudo apache2ctl configtest
Run Code Online (Sandbox Code Playgroud)
8) 如果配置文件没问题,重启apache服务器
sudo systemctl restart apache2
Run Code Online (Sandbox Code Playgroud)
9) 使用 certbot 设置证书并按照屏幕上的说明进行操作。
sudo certbot --apache
Run Code Online (Sandbox Code Playgroud)
Let's Encrypt 的所有证书有效期为 3 个月。要更新您可以手动运行
sudo certbot renew
Run Code Online (Sandbox Code Playgroud)
或将此服务作为 cron 作业自动化
sudo crontab -e
Run Code Online (Sandbox Code Playgroud)
并输入以下行以在每周一凌晨 2:30 调用续订。
. . .
30 2 * * 1 /usr/bin/certbot renew >> /var/log/le-renew.log
Run Code Online (Sandbox Code Playgroud)
您可以在此处遵循更详细的教程:https ://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-debian-8
小智 6
就我而言,我已通过在每个相关域的 apache ssl 配置文件中替换来解决此问题:
ServerName mydomain.com
ServerAlias www.mydomain.com
Run Code Online (Sandbox Code Playgroud)
经过 :
ServerName www.mydomain.com
ServerAlias mydomain.com
Run Code Online (Sandbox Code Playgroud)
因为我的证书适用于“www.mydomain.com”而不是“mydomain.com”
完整的阿帕奇文件:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin noreply@mydomain.com
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /home/mydomain.com/public_html
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
<Directory />
Options +FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/mydomain.com/public_html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
147487 次 |
| 最近记录: |