首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >让-加密错误:失败的HTTP-01飞行前/试运行

让-加密错误:失败的HTTP-01飞行前/试运行
EN

Stack Overflow用户
提问于 2020-01-10 19:21:21
回答 1查看 1.1K关注 0票数 3

我已经在它的自述文件示例之后建立了一个基于redbird的代理。

到目前为止,我已经为http和https配置了单域,并且它运行良好(https仍然使用自签名证书)。

但是现在我尝试将它配置为使用letsencrypt自动获得有效的ssl证书,并且我陷入了以下错误:

代码语言:javascript
复制
 {"level":30,"time":1578681102208,"pid":21320,"hostname":"nigul","name":"redbird","0":false,"1":"setChallenge called for 'exposito.bitifet.net'","msg":"Lets encrypt debugger","v":1}
[acme-v2] handled(?) rejection as errback:
Error: Error: Failed HTTP-01 Pre-Flight / Dry Run.
curl 'http://exposito.bitifet.net/.well-known/acme-challenge/test-cf55199519d859042f695e620cca8dbb-0'
Expected: 'test-cf55199519d859042f695e620cca8dbb-0.MgLl7GIS59DPtPMejuUcXfddzNt8YxfLVo5op670u8M'
Got: '<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>404 - Not Found</title>
 </head>
 <body>
  <h1>404 - Not Found</h1>
 </body>
</html>
'
See https://git.coolaj86.com/coolaj86/acme-v2.js/issues/4
    at /home/joanmi/SERVICES/redbird_domains/node_modules/acme-v2/index.js:49:10
    at process._tickCallback (internal/process/next_tick.js:68:7)

据我所知,这是告诉我让加密正在尝试使用以下命令访问url http://exposito.bitifet.net/.well-known/acme-challenge/test-cf55199519d859042f695e620cca8dbb-0

代码语言:javascript
复制
curl 'http://exposito.bitifet.net/.well-known/acme-challenge/test-cf55199519d859042f695e620cca8dbb-0'

它得到的...and似乎是一个404 HTML错误页面,我不知道它会出现在哪里。

而且,实际上,执行这个curl命令或者只是在我的浏览器中粘贴那个url (您可以尝试它:我让服务器运行),我得到了给定的预期字符串,因此,从我的观点来看,如果我的配置是正确的,但是出于某种原因,让加密的服务器到达另一个服务器(要么是因为错误的路由,要么是DNS)。

但另一方面,我想更有可能我在配置上做错了什么。

在这里,我粘贴我的整个脚本(端口80和443分别通过iptables重定向到1080和1443,因为脚本是由非特权用户运行的):

代码语言:javascript
复制
const Redbird = require("redbird");

const proxy = Redbird({
    port: 1080,
    xfwd: false, // Disable the X-Forwarded-For header
    letsencrypt: {
    path: __dirname + '/certs',
    port: 9999
            // LetsEncrypt minimal web server port for handling challenges.
            // Routed 80->9999, no need to open 9999 in firewall. Default 3000
            // if not defined.
    },
    ssl: {
        http2: true,
        port: 1443, // SSL port used to serve registered https routes with LetsEncrypt certificate.
    }

});


proxy.register('exposito.bitifet.net:9999', 'http://localhost:8001', {
  ssl: {
    letsencrypt: {
      email: 'xxxxxx@gmail.com', // Domain owner/admin email
      production: false,
                // WARNING: Only use this flag when the proxy is verified to
                // work correctly to avoid being banned!
    }
  }
});

proxy.register("exposito.bitifet.net", "http://localhost:8001");

任何线索都欢迎。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-14 13:20:24

解决了!!

同时也涉及到许多问题(尽管我对redbird和letsencrypt都缺乏经验。

  1. 魔术 404/Not页面:,我想它来自一个看起来已经预装在VPS中的lighttpd服务器。

端口80是通过iptable重定向的,但我想在一个或其他配置调整中,我可以将传入的请求重定向到localhost的端口80 (没有重定向)。

  1. 查看其自述文件中的示例,我认为redbird是某种程度上的"multi- reverse_proxy“,因为您可以用一个redbird实例重定向http和https请求。

但我终于意识到(可能不是很好的名称)端口选项实际上是一个http端口,它只用于配置内置的无条件http->https重定向器(我已经读过,但我认为它是可选的)。

  1. 实际的底层问题:,如果您的DNS激活了DNSSEC,您应该在其中定义一个指向letsencrypt.org的CAA寄存器。

现在,我禁用了DNSSEC,因为我的提供者的控制面板不允许我创建这样的寄存器。

我是在试图通过certbot (sudo apt-get install certbot )获得证书时发现的,我必须说,如果我以前知道它,我就不会关心尝试redbird的letsencrypt集成。

它要详细得多(当出现错误时,redbird更像一个黑匣子),并指出我需要CAA寄存器。

这里是我做的笔记(以防有人感兴趣):

代码语言:javascript
复制
Free SSL Certificates with Certbot
    Install certbot:
        sudo apt-get install certbot
    Create:
        sudo certbot certonly --manual --preferred-challenges http -d <domain>
    Renew:
        sudo certbot renew
    Caveats:
        DNSSEC
            If your DNS server has DNSSEC enabled, you will need to add a CAA
            register pointing to letsencrypt.org.
            ...and your DNS provider my not allow to create it (at least I
            couldn't with CDMON. Also not -yet- complained).
  1. production = false 用于其他类型的测试:--我读到,如果您在测试时输入了true,如果您执行了太多的请求,就可能被禁止使用letsencrypt。

将其设置为false,您可以测试重定向,但是您将看到有关letsencrypt的错误,甚至您可以在没有安全证书的情况下导航(我认为提供了某种自签名来允许测试)。所以不要指望一个有效的。

  1. ssl端口用于重定向:不是(大的)问题,但是如果指定ssl端口而不是443,则内置的重定向器将无条件地将您重定向到该端口。

以root用户身份运行redbird并使用标准端口(80和443)可以很好地工作。但是,如果您像我一样,希望使用其他端口来执行具有非特权用户的redbird,您将被重定向到该替代端口,而不是443 (甚至通过iptables重定向)。

在这里,我的(几乎*)最后的redbird脚本:

代码语言:javascript
复制
const Redbird = require("redbird");

const proxy = Redbird({
    port: 1080,
    xfwd: false, // Disable the X-Forwarded-For header
    ssl: {
        port: 1443,
    },
    letsencrypt: {
        path: __dirname + '/certs',
        port: 9999,
                // LetsEncrypt minimal web server port for handling challenges.
                // Routed 80->9999, no need to open 9999 in firewall. Default 3000
                // if not defined.
    },

});

proxy.register('exposito.bitifet.net', 'http://exposito.bitifet.net:8001', {
    ssl: {
        http2: true,
        letsencrypt: {
          email: 'xxxxxx@gmail.com', // Domain owner/admin email
          production: true,
                    // WARNING: Only use this flag when the proxy is verified to
                    // work correctly to avoid being banned!

        },
    }
});

(*)我仍然需要修复显式端口重定向问题(5),因为我不想将redbird作为root运行。但我知道允许用户监听给定端口是可能的。甚至我可能最好尝试修补redbird,以便允许分别指定、侦听和重定向端口。

编辑:它已经使用(可选)选项redirectPort在ssl部分实现(并记录在案)。刚刚添加了redirectPort: 443和工作完成!!

编辑2:为了完成,还有另一个问题我很难解决。

为了工作,我最终将重定向配置为http端口,而不是https端口。

也就是说: Incomming请求被重定向到我的应用程序http端口。

这听起来很奇怪,但很管用。至少,如果您不需要任何专门的https特性,比如推送通知(我计划在将来使用)。

但它意味着在本地主机上至少打开一个http服务器(至少)。这现在不是一个大问题(这只是一个游乐场服务器),但我计划在工作中使用redbird将多个域代理到不同的服务器,这样我们就不得不至少在DMZ中打开http (这是一个更好避免的额外风险……)。

当我尝试重定向到https时,我得到了DEPTH_ZERO_SELF_SIGNED_CERT错误。

好的:这告诉我redbird (或节点)不信任我的原始(自签名)证书。我知道有一个选项可以告诉节点接受这些证书。但也许这不是走的路..。

因此,我将我的应用程序配置为使用redbird通过letsencrypt获得的相同证书。

但后来我发现了另一个错误:

代码语言:javascript
复制
UNABLE_TO_VERIFY_LEAF_SIGNATURE

通过研究,我发现了这个StackOverflow的答案,它解释了如何获得Mozilla信任的所有根证书和中间证书,并使节点信任它们。

最后,我做的是:

  1. 已安装的node_extra_ca_certs_mozilla_bundle包: npm安装--保存node_extra_ca_certs_mozilla_bundle
  2. NODE_EXTRA_CA_CERTS=node_modules/node_extra_ca_certs_mozilla_bundle/ca_bundle/ca_intermediate_root_bundle.pem添加到Package.json脚本部分中的start命令。
  3. 更新了redbird脚本,再次指向https (协议和)端口: Proxy.register(‘Richito.bitifet.net’,'https://localhost:4301',{.];

这里是我最后的redbird配置:

代码语言:javascript
复制
const Redbird = require("redbird");

const proxy = Redbird({
    port: 1080,
    xfwd: false, // Disable the X-Forwarded-For header
    ssl: {
        port: 1443,
        redirectPort: 443
        // key: "/etc/bitifet/exposito/ssl/private.key",
        // cert: "/etc/bitifet/exposito/ssl/public.cert",
    },
    letsencrypt: {
        path: __dirname + '/certs',
        port: 9999,
                // LetsEncrypt minimal web server port for handling challenges.
                // Routed 80->9999, no need to open 9999 in firewall. Default 3000
                // if not defined.
    },

});

proxy.register('exposito.bitifet.net', 'https://localhost:4301', {
    ssl: {
        http2: true,
        letsencrypt: {
          email: 'xxxxxx@gmail.com', // Domain owner/admin email
          production: true,
                    // WARNING: Only use this flag when the proxy is verified to
                    // work correctly to avoid being banned!

        },
    }
});

在这里,我的package.json文件内容:

代码语言:javascript
复制
{
  "name": "redbird_domains",
  "version": "0.0.1",
  "description": "Local Domains Handling",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "NODE_EXTRA_CA_CERTS=node_modules/node_extra_ca_certs_mozilla_bundle/ca_bundle/ca_intermediate_root_bundle.pem node ./index.js"
  },
  "author": "Joanmi",
  "license": "GPL-3.0",
  "dependencies": {
    "node_extra_ca_certs_mozilla_bundle": "^1.0.4",
    "redbird": "^0.10.0"
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59687812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档