在Debian上强制HTTPS,您需要配置Web服务器(例如Apache或Nginx)以重定向所有HTTP请求到HTTPS
对于Apache:
sudo apt-get install apache2-mod_ssl
sudo apt-get install certbot python3-certbot-apache
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
将yourdomain.com和www.yourdomain.com替换为您的域名。按照提示操作,Certbot将自动配置Apache以使用HTTPS。
sudo certbot renew --dry-run
对于Nginx:
sudo apt-get install nginx ssl-cert
sudo apt-get install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
将yourdomain.com和www.yourdomain.com替换为您的域名。按照提示操作,Certbot将自动配置Nginx以使用HTTPS。
sudo certbot renew --dry-run
完成上述步骤后,您的Debian服务器上的网站将强制使用HTTPS。所有HTTP请求都将自动重定向到HTTPS。