node.js - 对于非 PHP/非静态文件网站,letsencrypt certbot-auto 的 "webroot-path"应该是什么?

标签 node.js apache flask lets-encrypt certbot

如果您有一个仅使用 Apache(可能使用 PHP)的网站,该网站位于:

/home/www/mywebsite/
/home/www/mywebsite/index.php
/home/www/mywebsite/style.css

然后,很容易设置certbot--webroot-path:

./certbot-auto certonly --webroot --webroot-path /home/www/mywebsite/
                        --domain example.com --domain www.example.com --email a@example.com
<小时/>

问题:使用 NodeJS 运行的网站时 或 Python Flask 或 Bottle,通过 WSGI (mod_wsgi) 或简单代理链接到 Apache(我知道在 Python 的情况下不推荐后者)

RewriteEngine On
RewriteRule /(.*)           http://localhost:5000/$1 [P,L]

--webroot-path 应该是什么?

更具体地说,如果我们有:

/home/www/mywebsite/       (Pyton example)
/home/www/mywebsite/myapp.py
/home/www/mywebsite/myapp.sqlite
/home/www/mywebsite/static/style.css
...

/home/www/mywebsite/        (NodeJS example)
/home/www/mywebsite/myapp.js
/home/www/mywebsite/myapp.sqlite
/home/www/mywebsite/static/style.css
...

那么选择 --webroot-path 作为 /home/www/mywebsite/ 是没有意义的,对吗?

确实,我不希望任何其他程序/脚本(例如 LetsEncrypt certbot)来摆弄我的 .py 文件。

无论如何,certbot 中的 --webroot-path 是做什么的?那里的文件会被分析、解析吗?

最佳答案

非常有趣的问题,但答案却很简单。官方文档指出:

The webroot plugin works by creating a temporary file for each of your requested domains in ${webroot-path}/.well-known/acme-challenge. Then the Let’s Encrypt validation server makes HTTP requests to validate that the DNS for each requested domain resolves to the server running certbot.

因此,对于 Certbot 来说,您的实际 webroot 实际驻留在哪里并不重要,只要它在您尝试获取证书的域下提供服务即可,并且它对您的项目是什么并不真正感兴趣/框架结构是。

换句话说,certbot 不需要访问包含源文件的项目目录。

例如,服务器上任何应用程序的 Apache 配置都可以共享所谓的 webroot,而 Certbot 只需要 /.well-known/acme-challenge/ 作为静态目录即可使用在服务器端存储可供 Certbot 验证服务器使用的质询文件:

Alias /.well-known/acme-challenge/ "/var/www/html/.well-known/acme-challenge/"

<Directory "/var/www/html/">
    AllowOverride None
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

在设置特定服务器 block 配置时,与 NGINX 的工作方式相同:

server {

    location /.well-known/acme-challenge/ {
        alias /var/www/html/.well-known/acme-challenge/;
    }

}

如果随后请求证书:

certbot-auto certonly --webroot --webroot-path /var/www/html -d domain.com

关于node.js - 对于非 PHP/非静态文件网站,letsencrypt certbot-auto 的 "webroot-path"应该是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49964315/

相关文章:

node.js - 无法使用 GridFS 从 MongoDB 流式传输视频

php - .htaccess mod_rewrite 中的加号和百分号

macos - 如何在 Mac Mavericks 上永久停止 apache?

python - Jinja2 for Flask 未拾取子模板

javascript - 使用 d3.js 将 SVG 转为 Canvas

javascript - 创建空字符串数组?

python - NGINX 不与 flask rest API 通信。 docker

python - 默认值不适用于 flask-sqlalchemy 中的反射模型

node.js - Nightmare 页面内容未加载 - 无法分配给对象 'onbeforeunload' 的只读属性 '#<Window>'

python - Django 源代码不会在服务器上更新