弃用lua resty auto ssl原因
lua resty auto ssl是配合openresty,基于Let's Encrypt 自动生成https证书的openresty组件,极大方便了上线的配置。但是我碰到的项目因为历史原因有将近20个域名的解析,将lua resty auto ssl部署上之后,会碰到shared memory zone "auto_ssl" was locked,直接导致443端口telnet不到。如果将域名搞成通配的,同样也会遇到问题: ssl_certificate.lua:260: set_response_cert(): auto-ssl: failed to set ocsp stapling for testd.letsdigg.com - continuing anyway同时配置.well-known/acme-challenge/ 配置这个必须占用80端口,而我的项目以前是使用elb的,也就是使用的是80端口,切换过程中就完全不能提供服务。netstat -anp | grep 443,会看到大量的CLOSE WAIT而且这个location的配置也迷惑了我好久,我用curl自己测试的时候显示404,最后看它的lua源码才知道,如果没有对应的token文件,会直接返回404,这个时候根本不知道是什么情况。所以选择返璞归真,使用Let's Encrypt申请通配域名。而且不用在配置中内置配置,基本生成证书即可。
Let's Encrypt通配域名的使用
下载cerbot-auto
wget https://dl.eff.org/certbot-auto
只生成证书模式
./certbot-auto certonly -d *.letsdigg.com --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
在生成证书过程中,配置dns解析
Please deploy a DNS TXT record under the name_acme-challenge.letsdigg.com with the following value: 一串字符串 Before continuing, verify the record is deployed.
最后生成证书
/etc/letsencrypt/live/letsdigg.com/fullchain.pem/etc/letsencrypt/live/letsdigg.com/privkey.pem
nginx配置
ssl_certificate /etc/letsencrypt/live/letsdigg.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/letsdigg.com/privkey.pem;
总结
https://groups.google.com/forum/#!topic/openresty/PGQnBWKyKmE至于造成443停止服务的情况,可以看下上面这个链接,里面大致有说明。最后附成功图: