• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

使用Caddy申请免费的Let’s Encrypt泛域名SSL证书

网络资源 Liam 1年前 (2019-05-03) 1287次浏览 19个评论 扫描二维码
文章目录[隐藏]

说明:之前看到有人问了下Caddy怎么申请Let’s Encrypt泛域名SSL证书,就翻了下官方文档了解下,发现比用Nginx申请的过程简单很多,这里就发下方法。如果有人需要Nginx申请的方法,可以看下博主很久前发过的Nginx申请教程→传送门

说明

Caddy支持以下DNS服务商,所以需要提前将你的域名DNS服务器转移到指定服务商。

cloudflare、cloudxns、dnspod、gandi/gandiv5、godaddy、namecheap、vultr、googlecloud、auroradns、azure、    digitalocean、dnsimple、dnsmadeeasy、dyn、lightsail、linode、ns1、namedotcom、ovh、otc、pdns、rackspace、rfc2136、route53 

申请

由于博主的域名DNS都在CloudFlare,所以下面以CF为例。

1、安装Caddy

curl https://getcaddy.com | bash -s personal tls.dns.cloudflare

后面的tls.dns.cloudflarecloudflare的插件,如果你是其它DNS服务商就需要替换下插件参数,比如:

tls.dns.auroradns tls.dns.azure tls.dns.cloudflare tls.dns.cloudxns tls.dns.digitalocean tls.dns.dnsimple tls.dns.dnsmadeeasy tls.dns.dnspod tls.dns.dyn tls.dns.exoscale tls.dns.gandi tls.dns.gandiv5 tls.dns.godaddy tls.dns.googlecloud tls.dns.lightsail tls.dns.linode tls.dns.namecheap tls.dns.ns1 tls.dns.otc tls.dns.ovh tls.dns.powerdns tls.dns.rackspace tls.dns.rfc2136 tls.dns.route53i tls.dns.vultr 

2、设置环境变量
以下为Caddy申请通配符时所需要的DNS服务商的环境变量。

#Aurora DNS by PCExtreme AURORA_USER_ID AURORA_KEY AURORA_ENDPOINT(optional)  #Azure DNS AZURE_CLIENT_ID AZURE_CLIENT_SECRET AZURE_SUBSCRIPTION_ID AZURE_TENANT_ID  #Cloudflare CLOUDFLARE_EMAIL CLOUDFLARE_API_KEY  #CloudXNS CLOUDXNS_API_KEY CLOUDXNS_SECRET_KEY  #DigitalOcean DO_AUTH_TOKEN  #DNSimple DNSIMPLE_EMAIL DNSIMPLE_OAUTH_TOKEN  #DNS Made Easy DNSMADEEASY_API_KEY DNSMADEEASY_API_SECRET DNSMADEEASY_SANDBOX(true/false)  #DNSPod DNSPOD_API_KEY  #DynDNS DYN_CUSTOMER_NAME DYN_USER_NAME DYN_PASSWORD  #Gandi/Gandiv5 GANDI_API_KEY/GANDIV5_API_KEY  #GoDaddy GODADDY_API_KEY GODADDY_API_SECRET  #Google Cloud DNS     GCE_PROJECT GCE_DOMAIN GOOGLE_APPLICATION_CREDENTIALS  #Lightsail by AWS AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN(optional) DNS_ZONE(optional)  #Linode LINODE_API_KEY  #Namecheap NAMECHEAP_API_USER NAMECHEAP_API_KEY  #NS1 NS1_API_KEY  #Open Telekom Cloud Managed DNS OTC_DOMAIN_NAME OTC_USER_NAME OTC_PASSWORD OTC_PROJECT_NAME OTC_IDENTITY_ENDPOINT(optional)  #OVH OVH_ENDPOINT OVH_APPLICATION_KEY OVH_APPLICATION_SECRET OVH_CONSUMER_KEY  #PowerDNS PDNS_API_URL PDNS_API_KEY  #Rackspace RACKSPACE_USER RACKSPACE_API_KEY  #RFC2136 RFC2136_NAMESERVER RFC2136_TSIG_ALGORITHM RFC2136_TSIG_KEY RFC2136_TSIG_SECRET  #Route53 by AWS     AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY  #Vultr VULTR_API_KEY

这些变量值可以在DNS服务商账户中查找,一般在设置什么的地方。然后这里以CloudFlare为例,先登录账号,然后再去获取APIAPI获取地址:https://www.cloudflare.com/a/profile
使用Caddy申请免费的Let’s Encrypt泛域名SSL证书
再使用命令设置环境变量:

export CLOUDFLARE_API_KEY="4993d7315d4c72770242357da"  #CloudFlare账户API export CLOUDFLARE_EMAIL="[email protected]"  #CloudFlare账户邮箱 

3、获取通配符
先新建配置文件,使用命令:

#将域名修改为自己的,然后将下面全部一起复制到SSH客户端运行 echo "*.moerats.com { tls {     dns cloudflare } }" > Caddyfile

这里如果你是其它DNS服务商就需要修改dns后面的参数,也就是服务商名称,均用小写字母,可以参考步骤1安装caddy的插件参数,比如插件为tls.dns.auroradns,那就用dns auroradns参数。

然后启动Caddy

caddy -conf Caddyfile

接下来几秒钟后,会自动给你生成一个通配符SSL证书,证书存放路径为:

~/.caddy/acme/acme-v02.api.letsencrypt.org/sites/wildcard_.moerats.com 

此时你就可以使用crtkey文件为你的所有子域名配置SSL了。

最后证书有效期依然是3个月,到期后可以重新用此方法申请。
使用Caddy申请免费的Let’s Encrypt泛域名SSL证书


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用Caddy申请免费的Let’s Encrypt泛域名SSL证书
喜欢 (2)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(19)个小伙伴在吐槽
  1. Great blog! Do you have any hints for aspiring writers? I'm planning to start my own blog soon but I'm a little lost on everything. Would you advise starting with a free platform like Wordpress or go for a paid option? There are so many choices out there that I'm completely overwhelmed .. Any suggestions? Cheers!
    black mass2020-08-31 11:46 回复 Linux | Firefox浏览器 52.9
  2. I must thank you for the efforts you have put in penning this website. I am hoping to see the same high-grade blog posts by you in the future as well. In fact, your creative writing abilities has inspired me to get my very own site now ;)
    cheap flights2020-08-28 11:04 回复 Linux | Chrome 56.0.2924.87
  3. I just couldn't leave your site before suggesting that I actually loved the standard info a person provide to your visitors? Is gonna be back regularly to check up on new posts 32hvAj4 cheap flights
    cheap flights2020-08-25 21:54 回复 Linux | Chrome 65.0.3325.181
  4. Undeniably imagine that that you stated. Your favorite justification appeared to be on the net the simplest thing to keep in mind of. I say to you, I certainly get annoyed whilst other folks consider worries that they plainly don't understand about. You managed to hit the nail upon the highest and also defined out the entire thing without having side-effects , people can take a signal. Will likely be again to get more. Thanks
    best hosting2020-08-25 18:42 回复 Linux | Chrome 66.0.3359.106
  5. That is a good tip particularly to those new to the blogosphere. Short but very precise information… Appreciate your sharing this one. A must read article! cheap flights yynxznuh
    cheap flights2020-08-25 06:10 回复 Linux | Firefox浏览器 52.9
  6. I do trust all of the ideas you have presented in your post. They are really convincing and can definitely work. Nonetheless, the posts are too short for beginners. May you please prolong them a little from subsequent time? Thanks for the post.
    best web hosting sites2020-08-14 22:25 回复 Linux | Chrome 65.0.3325.183
  7. I think this is among the such a lot vital information for me. And i'm satisfied studying your article. However should commentary on some common issues, The site style is wonderful, the articles is in point of fact great : D. Excellent activity, cheers
    web hosting sites2020-08-07 23:47 回复 Linux | Chrome 66.0.3359.139
  8. My family always say that I am wasting my time here at web, but I know I am getting know-how daily by reading thes pleasant articles or reviews. adreamoftrains best website hosting
    adreamoftrains web hosting2020-07-30 18:53 回复 Linux | Firefox浏览器 61.0
  9. you're in reality a just right webmaster. The web site loading pace is amazing. It kind of feels that you're doing any unique trick. In addition, The contents are masterwork. you have done a fantastic activity on this matter!
    airfares2020-07-28 11:33 回复 Linux | Chrome 66.0.3359.106
  10. Yes! Finally something about air flights cheap.
    cheap flights with jet2 com2020-07-27 18:57 回复 Linux | Firefox浏览器 52.9
  11. I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz respond as I'm looking to design my own blog and would like to know where u got this from. thank you
    web hosting companies2020-07-27 04:45 回复 Windows Vista | Chrome 4.0.202.2
  12. I've been exploring for a little for any high-quality articles or weblog posts on this kind of house . Exploring in Yahoo I at last stumbled upon this website. Reading this information So i'm happy to express that I have an incredibly good uncanny feeling I found out just what I needed. I such a lot unquestionably will make certain to don?t put out of your mind this web site and provides it a look on a relentless basis.
    best web hosting sites2020-07-26 07:01 回复 Linux | Firefox浏览器 60.0.2
  13. hello there and thank you for your information – I have certainly picked up something new from right here. I did however expertise some technical points using this site, as I experienced to reload the web site many times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will sometimes affect your placement in google and can damage your high quality score if ads and marketing with Adwords. Well I am adding this RSS to my email and could look out for a lot more of your respective exciting content. Ensure that you update this again very soon.
    web hosting services2020-07-23 07:40 回复 Linux | Chrome 66.0.3359.139
  14. I’m not that much of a online reader to be honest but your blogs really nice, keep it up! I'll go ahead and bookmark your site to come back in the future. All the best
    best website hosting2020-07-22 05:52 回复 Linux | Firefox浏览器 52.9
  15. Hello there, I discovered your web site by the use of Google even as looking for a comparable topic, your web site came up, it looks good. I have bookmarked it in my google bookmarks. Hi there, simply was aware of your blog thru Google, and found that it is really informative. I am going to be careful for brussels. I'll be grateful in the event you continue this in future. Lots of folks might be benefited out of your writing. Cheers!
    web hosting companies2020-07-18 08:05 回复 Linux | Chrome 67.0.3396.62
  16. Great work! This is the type of information that are supposed to be shared around the net. Shame on Google for not positioning this put up higher! Come on over and discuss with my site . Thanks =)
    web hosting companies2020-07-16 20:03 回复 Windows 8.1 | Firefox浏览器 59.0
  17. Pretty nice post. I just stumbled upon your blog and wished to mention that I've truly loved surfing around your blog posts. In any case I will be subscribing on your rss feed and I'm hoping you write again very soon!
    cbd oil that works 20202020-06-29 18:36 回复 Linux | Chrome 56.0.2924.87
  18. This paragraph will help the internet people for setting up new website or even a weblog from start to end.
    cbd oil that works 20202020-06-27 23:28 回复 Linux | Chrome 67.0.3394.0
  19. Hi, Neat post. There's a problem together with your site in web explorer, would check this? IE nonetheless is the market leader and a huge part of folks will pass over your excellent writing because of this problem.
    g rsacwgxy2020-06-23 07:36 回复 Windows 8.1 | Chrome 66.0.3359.181