大网数据广告活动
服务器运维问答

How to have apache handle .well-known/acme-challenge and still have / passed to wsgi

· 52CE 我爱测

In order to support automatic LetsEncrypt certificate renewal certbot uses the --apache handler. e.g. certbot renew --apache This handler installs a temporary VirtualHost for */.well-known/acme-challenge/ on the Apache server in …

问题原文

原帖链接 · Jay M · CC BY-SA 4.0

In order to support automatic LetsEncrypt certificate renewal certbot uses the --apache handler.

e.g.

certbot renew --apache

This handler installs a temporary VirtualHost for */.well-known/acme-challenge/ on the Apache server in order authenticate the renewal.

The problem is that this mechanism does not work if the existing virtual server uses HTTPS and Django over WSGI mounted on the http server root.

The temporary VirtualHost fails to capture the URL and so Django tries to service the request (and fails) as the URL is not in it's list of URLs.

已采纳解答

原帖链接 · Jay M · CC BY-SA 4.0

Writing the question made me think about how it works, so I then worked out the answer. As I could not find an answer to what must be a common issue I thought I'd post what I have found.

There are other solutions, E.g. certbot-django and django-letsencrypt but both are fare more hastle than just letting the stock certbot handle it.

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>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。