在我的.net核心应用程序的日志中,我可以看到所有请求的URL都以反斜杠为前缀。该应用程序使用.net core 2.0托管在Amazon Linux 2上。以下是请求中使用网址的方式:http://www.mvc.meetcorepoint.com/
此处是.net核心http://\www.mvc.meetcorepoint.com/
收到的网址。以下是日志的一部分,其中也显示了其他网址:
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
dotnet-ids.mvc[22185]: Request starting HTTP/1.1 GET http://\www.mvc.meetcorepoint.com/
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
dotnet-ids.mvc[22185]: Executing action method MvcClient.Controllers.HomeController.Index (MvcClient) with arguments ((null)) -
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
dotnet-ids.mvc[22185]: Executing ViewResult, running view at path /Views/Home/Index.cshtml.
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
dotnet-ids.mvc[22185]: Executed action MvcClient.Controllers.HomeController.Index (MvcClient) in 0.5249ms
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
dotnet-ids.mvc[22185]: Request finished in 0.7982ms 200 text/html; charset=utf-8
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
dotnet-ids.mvc[22185]: Request starting HTTP/1.1 GET http://\www.mvc.meetcorepoint.com/lib/bootstrap/dist/css/bootstrap.css
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
dotnet-ids.mvc[22185]: Sending file. Request path: '/lib/bootstrap/dist/css/bootstrap.css'. Physical path: '/var/www/dotnet/ids
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
dotnet-ids.mvc[22185]: Request finished in 1.6629ms 200 text/css
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
dotnet-ids.mvc[22185]: Request starting HTTP/1.1 GET http://\www.mvc.meetcorepoint.com/css/site.css
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
dotnet-ids.mvc[22185]: Sending file. Request path: '/css/site.css'. Physical path: '/var/www/dotnet/ids.mvc/wwwroot/css/site.cs
dotnet-ids.mvc[22185]: info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
dotnet-ids.mvc[22185]: Request finished in 0.3626ms 200 text/css
答案 0 :(得分:1)
事实证明,这与Linux无关,也与.net核心本身无关。问题出在我的nginx配置中,它被用作.net核心应用程序的反向代理。当我从网络上处理代理nginx配置时,它以某种方式在Upgrade
和Host
标头上添加了反斜杠。因此,我没有proxy_set_header Host $host;
使用proxy_set_header Host \$host;