我需要支持RESTfull api和Grpc一起(没有TLS),所以我在appsettings.json
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://+:4998"
},
"Grpc": {
"Url": "http://+:4999",
"Protocols": "Http2"
}
}
}
当我在VS中启动应用程序时,我得到这个警告:
覆盖地址(es)"http://localhost: 4999"。绑定到端点通过IConfiguration和/或UseKestrel()定义。
问题是双url配置。首先是launchSettings.json
中的"applicationUrl"
,然后是appsettings.json
文件中的Kestrel
部分。为了解决这个问题,我按照这个答案的建议将"externalUrlConfiguration": true
添加到launchSettings.json
文件中。
现在,我在Dockerfile
中使用以下配置启动Docker容器中的应用程序ENV DOTNET_Kestrel__Endpoints__Http__Url=http://+:80
ENV DOTNET_Kestrel__Endpoints__Grpc__Url=http://+:8080
ENV DOTNET_Kestrel__Endpoints__Grpc__Protocols=Http2
再次得到这个警告
覆盖地址(es)"http://+: 80"。绑定到通过IConfiguration和/或UseKestrel()定义的端点。
这次是因为碱基Asp。Net Core映像配置ASPNETCORE_URLS=http://+:80
环境变量,然后我用Kestrel__Endpoints
覆盖它。
有没有办法避免这个警告?
使用ENV重置ASPNETCORE_URLS="帮助吗?- - - - - -Rhumborl5月26日13:11