Kri*_*ner 5 iis ssl static-files staticfilehandler asp.net-core
我在我的@home网络服务器上使用https://github.com/ebekker/ACMESharp作为我的SSL(它是免费的!:O).这是非常手动的,但在维基上注意到它提到了https://github.com/Lone-Coder/letsencrypt-win-simple上的另一个项目,这是一个用于自动申请,下载和安装SSL的GUI证书到您的网络服务器.
GUI用于验证域的方法是您的,通过创建一个随机命名的文件,其中包含一个随机的文本字符串,其中[webroot]/.well-known/[randomFile]包含扩展名.使用.dotnetcore应用程序在此[webroot]上运行,即使遵循IIS下更改"处理程序映射"的说明,我也无法提供该文件.
看起来我可以通过直接导航到他们来提供文件[webRoot]/wwwroot/[whatever]- 所以为什么我不能进入[webroot]/.well-known/[randomFile]?
有人知道解决这个问题吗?我可以删除.netcore应用程序,然后运行SSL证书安装,但这个安装需要每2-3个月进行一次,因为它是手动的,我更愿意弄清楚如何以正确的方式做到这一点.
我在这里找到了我需要的信息:https ://docs.asp.net/en/latest/fundamentals/static-files.html
基本上在我的 Statup.cs 中我需要改变这一点:
// allows for the direct browsing of files within the wwwroot folder
app.UseStaticFiles();
// MVC routes
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
对此:
// allows for the direct browsing of files within the wwwroot folder
app.UseStaticFiles();
// Allow static files within the .well-known directory to allow for automatic SSL renewal
app.UseStaticFiles(new StaticFileOptions()
{
ServeUnknownFileTypes = true, // this was needed as IIS would not serve extensionless URLs from the directory without it
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @".well-known")),
RequestPath = new PathString("/.well-known")
});
// MVC routes
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
编辑 - 请注意,这个目录“.well-known”仅在 Web 服务器上创建,当我开始在本地再次开发时,我收到错误,因为“.well-known”目录不存在。所以现在我的项目中只有一个空目录,但至少我的 SSL 续订是自动的!:D
| 归档时间: |
|
| 查看次数: |
979 次 |
| 最近记录: |