c# - .net 将 https 连接到 nginx 时看不到静态文件
问题描述
我在 DotNet 项目上连接的 https 协议有问题。
我在cloudflare服务上创建了一个证书,上传到我的VPS服务器,但是,如果之前通过IP地址打开站点时,站点可以正常打开
但是当连接到https://example.com时,我在位于 wwwroot 目录中的静态文件上收到 404 错误。
服务器:Linux Ubuntu 18.04、nginx、DotNet
我有标准项目设置
启动.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
程序.cs
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:9580")
.UseStartup<Startup>();
}
加载资源失败:服务器响应状态为 404 ()
是我得到的错误,但在http://xxx.xxx.xxx.xxx上它工作正常。
解决方案
推荐阅读
- vb.net - 连接字符串函数
- eclipse - Eclipse:有没有办法打开所有修改过的文件?
- c# - 如何动态绑定数据到自适应卡?
- r - 抖动图中的订单天数
- django - 当我在 django 管理站点中注册模型时,如何使用标签列表更改字段名称
- ios - 自定义 TableViewCells 在重新加载 tableview 时闪烁
- java - Java:为什么我不能在一个语句中声明引用变量并在类的另一个语句中创建引用对象?
- mysql - 使用 group by 和 joins 时无法获取每天的最后订单金额
- php - 错误:类 Illuminate\Database\Eloquent\Builder 的对象无法转换为字符串
- eclipse - 如何将 Eclipse IDE 与 Databricks 集群集成