gpt4 book ai didi

angularjs - ASP.Net 应用程序干扰远程主机 Let's Encrypt(通过 Plesk)安装?

转载 作者:行者123 更新时间:2023-12-02 22:56:27 25 4
gpt4 key购买 nike

因此,要安装 Let's Encrypt SSL 证书,我需要转到我的 Plesk 帐户,选择一个域或子域并单击 Let's Encrypt,然后我只有一个用于输入电子邮件地址的字段和一个用于安装的按钮。

要安装,Let's Encrypt 会向我的网站发送 HTTP 请求:

GET /.well-known/acme-challenge/n9cD8Lpv-woEU73NhCUdFyqOYMc5hrANF_byoiaYrZc - HTTP/1.1

如果我通过 Plesk 创建一个新的“站点”,并安装证书,则 GET 请求会得到一个很好的 200 响应,并且 SSL 证书安装正常。

但是,我有一个未安装 SSL 的“沙箱”,然后我将 ASP.NetCore 应用程序部署到“沙箱”进行暂存,然后尝试安装 SSL 证书。当 ASP.NetCore 应用程序运行时,当 Let's Encrypt 发送 GET 请求时,会导致 404 错误并且安装失败。

有人遇到过这种情况吗?我需要配置什么?是 MVC 路由还是 AngularJS (~1.5) 路由在干扰?

我在任何地方都没有看到/.well-known/* 目录,我不确定它是否被隐藏,但我无法访问它,所以如果我需要的话,我怎么知道要配置什么在路由中配置某些内容以允许 GET/.well-known/acme-challenge/*?

远程主机技术支持没有任何帮助。他们告诉我要等 72 小时,因为我尝试了很多次,但我只是被锁在门外(但我没有)

这是实际的 Plesk 错误消息

Let's Encrypt SSL certificate installation failed: Challenge marked as invalid. Details: Invalid response from http://my-domain.net/.well-known/acme-challenge/AJsMc3HXiOZRGaFVsMR3uZEdYu1moJ2Po62t3e6uV10 [my-ip]: 404

我相当确定我可以通过删除我的网站、安装 SSL 证书而不是再次上传来“解决”这个问题,但我想知道到底发生了什么,以及我是否可以正确处理它。

事后思考

Let's Encrypt 是一项 30 天自动续订服务。如果我的 ASP.NET 应用程序阻止安装,那么它也会阻止自动续订,因此我必须每 30 天删除我的网站并重新部署,这是 Not Acceptable !

已解决这是针对这个非常具体的场景的解决方案。

还有其他可行的解决方案,当然此解决方案仅适用于 IIS Web 服务器。

ASPNetCore MVC Routing Let Server Handle Specific Route

最佳答案

快速搜索后发现了这个小 gem

这似乎符合您的特定问题。

To get a certificate, let’s encrypt verify that you own the domain byrequesting a file on your server. In this case, the file is notaccessible (status 404). Let’s understand what happened.

IIS get the request, and find the associated web site. Then itexecutes handlers in order until one send the response. ASP.NET Corehandler is the first to handle the request.

The challenge file is in the folder “.well-known/…”, but by defaultASP.NET Core serves only files located in the folder “wwwroot” => so,a 404 response is send to the client. ASP.NET Core has handled therequest; therefore, the IIS Static file handler is not called.

As a workaround, you can move up the “StaticFile” handler, but yourwebsite may not work as expected. A better solution is to instructyour ASP.NET Core website to send the file located in the directory“.well-known”.

This is possible by registering it:

public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
//...other configs

app.UseStaticFiles(); // wwwroot

var wellKnownDirectory = Path.Combine(Directory.GetCurrentDirectory(), @".well-known");
if (!Directory.Exists(wellKnownDirectory))
Directory.CreateDirectory(wellKnownDirectory);

app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(wellKnownDirectory),
RequestPath = new PathString("/.well-known"),
ServeUnknownFileTypes = true // serve extensionless file
});

//...other configs

app.UseMvc();
}

这基本上通过核心路由对虚拟路径的调用,核心获取物理路径并向调用者提供文件内容。现在应该允许验证域并让证书请求流程完成并自动续订。

查看该文章及其建议的解决方法,因为似乎没有涉及太多其他步骤。

关于angularjs - ASP.Net 应用程序干扰远程主机 Let's Encrypt(通过 Plesk)安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44732729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com