nginx 配置https

上文介绍了可能在freenom 上申请免费域名,对于一些小型站点,为了降低建站成本,可以申请免费的https证书。
本文采用let's Encrypt 免费的https证书,由于let's Encrypt配置比较繁琐,官方提供了自动化客户端工具certbot 用于管理证书。
 

一. 生成证书

yum install -y certbot
certbot certonly --standalone -d test.ml

证书默认生成目录:/etc/letsencrypt/live/test.ml/
 

二. nginx配置https

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  test.ml;
	ssl_certificate /data/fullchain.pem;
	ssl_certificate_key /data/privkey.pem;

	# 调优参数
	ssl_protocols TLSv1.2 TLSv1.3;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_session_tickets on;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    ssl_buffer_size 1400;
    add_header Strict-Transport-Security max-age=15768000;
    ssl_stapling on;
    ssl_stapling_verify on;

	location / {
		proxy_pass    http://127.0.0.1:8080;
		proxy_redirect             off;
		proxy_http_version         1.1;
		proxy_set_header Upgrade   $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_set_header Host      $http_host;
    }
}

 

三. 证书续期

letencrpt 证书有效期为3个月,Let's Encrypt会在到期30天,10天分别发送证书到期邮件提醒。只需要重新生成证书即可

certbot renew

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值