网站以 HTTPS(HyperText Transfer Protocol Secure)开头,主要是为了保障数据传输的安全性、完整性和用户隐私。以下是主要原因:
适用场景:登录页面、支付页面、医疗或金融类网站必须使用 HTTPS,否则用户数据可能暴露在公共网络中。
增强信任:地址栏显示“锁”图标或企业名称(EV 证书),提升用户对网站的信任感。
数据完整性 防篡改:HTTPS 通过加密和哈希算法确保数据在传输过程中不被恶意修改(如插入广告、劫持内容)。
浏览器和搜索引擎的强制要求 安全警告:Chrome、Firefox 等浏览器会对 HTTP 网站标记为“不安全”,可能导致用户流失。
SEO 优化:Google 等搜索引擎优先收录 HTTPS 网站,影响搜索排名。
新功能支持:部分现代 Web 功能(如地理位置、Service Worker、PWA)仅限 HTTPS 使用。
行业标准:金融、医疗、教育等领域普遍强制要求 HTTPS。
TLS 1.3 优化:新一代 TLS 协议减少了加密延迟,性能接近甚至优于 HTTP。
我们的服务器系统是 almalinux 所以现在我们实际操作一下
使用 certbot 工具自动获取并配置证书:
sudo yum install certbot python3-certbot-nginx
安装成功后然后执行
sudo certbot --nginx
然后Certbot 要求输入电子邮件地址时,这是为了:
紧急证书续订提醒(证书到期前会通知)
安全事件通知(如密钥泄露等风险)
如何操作? 建议输入真实邮箱(如 yourname@example.com),按回车继续。
若不想提供,可输入 临时邮箱(如临时匿名邮箱服务生成的地址),但可能错过重要通知。
后续步骤(输入邮箱后): 需要同意 Let's Encrypt 的服务条款(输入 Y 确认)。
选择是否订阅 EFF 的邮件列表(可选 N 跳过)。
选择要为哪个 Nginx 域名配置 HTTPS(Certbot 会自动检测服务器配置的域名)。
Enter email address: your_email@example.com # 输入你的邮箱
- - - - -
(A)gree/(C)ancel: Y # 同意条款
- - - - -
(Y)es/(N)o: N # 不订阅邮件
- - - - -
Select domains for HTTPS: 1 # 选择要启用 HTTPS 的域名(按数字编号)
- - - - -
(1) Keep HTTPS always on/(2) Redirect HTTP to HTTPS: 2 # 推荐选2(强制跳转HTTPS)
然后ssl就配置成功啦,我们就可以通过https://你自己的域名 访问我们的网站了。
实际我们的项目有很多个,那么我们需要继续申请证书,那么如何操作呢,其实很简单,我们只需要单独申请证书就好了,
sudo certbot certonly --nginx -d ad.gyqtt.cn
sudo certbot certonly --nginx -d 你的域名
# 其他域名同理
我们可以看到运行结果
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for d.gyqtt.cn
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/d.gyqtt.cn/fullchain.pem
Key is saved at: /etc/letsencrypt/live/d.gyqtt.cn/privkey.pem
This certificate expires on 2025-07-19.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
本文为谷永庆原创文章,转载无需和我联系,但请注明来自luffy博客http://gyqtt.cn
Recent Comments