Jay*_*y M 7 django wsgi lets-encrypt apache2
为了支持自动 LetsEncrypt 证书续订,certbot 使用--apache处理程序。
例如
certbot renew --apache
Run Code Online (Sandbox Code Playgroud)
该处理程序在 Apache 服务器上为*/.well-known/acme-challenge/安装一个临时 VirtualHost ,以验证续订。
问题是,如果现有虚拟服务器使用安装在 http 服务器根目录上的 HTTPS 和 Django over WSGI,则此机制不起作用。
临时 VirtualHost 无法捕获 URL,因此 Django 尝试为请求提供服务(但失败),因为该 URL 不在其 URL 列表中。
写下这个问题让我思考它是如何运作的,所以我然后找出了答案。由于我无法找到常见问题的答案,因此我想我应该发布我所发现的内容。
还有其他解决方案,例如certbot-django和django-letsencrypt,但这两种解决方案都比仅仅让库存 certbot 处理它更麻烦。
The --apache certbot handler places it's files in /var/lib/letsencrypt/http_challenges, so all that is required is to have Apache handle those files in the same way as the docs recommend for static files.
<VirtualHost *:443>
[....SSL stuff]
AliasMatch /.well-known/acme-challenge/(.*)$ /var/lib/letsencrypt/http_challenges/$1
<directory /var/lib/letsencrypt/http_challenges>
AllowOverride None
Require all granted
</directory>
[....WSGI stuff]
WSGIScriptAlias / /opt/myserver/myapp/wsgi.py
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7226 次 |
最近记录: |