我刚刚在ubuntu上使用certbot安装了ssl证书。我使用了sudo certbot --nginx
命令进行安装,然后选择了将网站重定向到https
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): 2
No matching insecure server blocks listening on port 80 found.
由于某种原因,该方法不起作用,因此我决定手动进行操作,但由于我将apache2用作反向代理,而将nginx用作主机服务,我感到困惑。
Apache2
<VirtualHost *:80>
Servername mail.aboutryansam.com
Redirect permanent / https://mail.aboutryansam.com
ProxyPass / http://aboutryansam.com:81/
ProxyPassReverse / http://aboutryansam.com:81/
</VirtualHost>
Nginx
server {
listen 81;
listen [::]:81 ipv6only=on;
server_name mail.aboutryansam.com;
location / {
root /var/www/nginx/mail.aboutryansam.com;
index index.html index.htm;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mail.aboutryansam.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mail.aboutryansam.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
如果您寻找自己的http://mail.aboutryansam.com,它仍然不会重定向。我也尝试过使重定向也发生在Nginx上,并且它也不起作用。有人知道我应该重定向到哪个服务器,或者我在这里做错了什么?