我正在尝试在Linode服务器上使用HTTPS建立网站。它可以在HTTP上工作,但不能在HTTPS上工作。
我尝试使用Certbot为HTTPS配置我的域。
root@mailer9:/etc/apache2/sites-enabled# sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mailer9.com
2: www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Attempting to parse the version 0.29.1 renewal configuration file found at /etc/letsencrypt/renewal/mailer9.com.conf with version 0.28.0 of Certbot. This might not work.
Cert not yet due for renewal
You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/mailer9.com.conf)
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for mailer9.com
http-01 challenge for www.mailer9.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Your existing certificate has been successfully renewed, and the new certificate
has been installed.
The new certificate covers the following domains: https://mailer9.com and
https://www.mailer9.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mailer9.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/mailer9.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/mailer9.com/privkey.pem
Your cert will expire on 2019-04-02. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
root@mailer9:/etc/apache2/sites-enabled#
它说应该可以正常工作,但不能在HTTPS模式下工作。
在启用站点的目录中看到两个VH文件。
root@mailer9:/etc/apache2/sites-enabled# cat mailer9.com.conf
# domain: mailer9.com
# public: /var/www/html/mailer9.com/public_html/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin xxx@yy.com
ServerName mailer9.com
ServerAlias www.mailer9.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/mailer9.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/mailer9.com/log/error.log
CustomLog /var/www/html/mailer9.com/log/access.log combined
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =mailer9.com [OR]
#RewriteCond %{SERVER_NAME} =www.mailer9.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
由Certbot自动生成的另一种HTTPS。
root@mailer9:/etc/apache2/sites-enabled# cat mailer9.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin xxx@yy.com
ServerName mailer9.com
ServerAlias www.mailer9.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/mailer9.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/mailer9.com/log/error.log
CustomLog /var/www/html/mailer9.com/log/access.log combined
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mailer9.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mailer9.com/privkey.pem
</VirtualHost>
</IfModule>
root@mailer9:/etc/apache2/sites-enabled#
但是,如果我访问http://mailer9.com/,则可以正常工作。但是,如果我转到https://mailer9.com/,则该页面无法加载。我不知道如何解决,对我来说一切都很好。
Apache模块命令apachectl -M
显示ssl_module已加载。
答案 0 :(得分:0)
这是由于 ufw 防火墙引起的。我添加了端口443,并对其进行了修复。
sudo ufw allow 443/tcp