我想我找到问题了,我之前是这样写的:
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d example.com -d www.example.com --keylength"
而正确的写法应该是:
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d example.com --keylength"
注意最后一行,我之前包含了 example.com 和 www.example.com。
我还把 return 301 https://$host$request_uri; 改成了 return 301 $scheme://$host$request_uri;,重新构建后看起来已经可以正常工作了。
现在我唯一担心的是 @Stephen 提到的,如果 letsencrypt 的配置发生变化,可能会导致问题。