简体   繁体   English

带Nginx代理的Docker上的.NET Core API 502错误网关

[英].NET Core API 502 Bad Gateway on Docker w/ Nginx Proxy

I am hosting a .NET Core web API process in a docker container, with a Nginx reverse proxy. 我正在使用Nginx反向代理在Docker容器中托管.NET Core Web API进程。 I can send a request, and I get back the expected responses. 我可以发送请求,然后得到预期的响应。 There is one issue that I can't seem to figure out. 我似乎无法弄清一个问题。 Every few hours, my API requests begin getting a 502 Bad Gateway error response. 每隔几个小时,我的API请求就会开始收到502 Bad Gateway错误响应。 If I stop and restart the docker container for the API, the errors stop and everything goes back to normal. 如果我停止并重新启动API的docker容器,则错误停止,一切恢复正常。

  • I'm running .NET Core 2.1.1. 我正在运行.NET Core 2.1.1。
  • The host machine for the docker containers is Centos 7. Docker容器的主机是Centos 7。
  • I have other containers running as part of this application that do not have problems 我有其他没有问题的容器作为此应用程序的一部分运行

Thoughts anybody? 有任何想法吗?

The problem I described is fixed. 我描述的问题已解决。 I found that issue resolved itself when I changed my Dockerfile base image. 当我更改Dockerfile基本映像时,我发现该问题自行解决。 When updating my API to .NET Core 2.1.1, I decided to use this image in my Dockerfile: FROM microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine3.7 将我的API更新到.NET Core 2.1.1时,我决定在Dockerfile中使用此映像: FROM microsoft / dotnet:2.1.1-aspnetcore-runtime-alpine3.7

I changed that line to this: FROM microsoft/dotnet:2.1-aspnetcore-runtime 我将该行更改为: FROM microsoft / dotnet:2.1-aspnetcore-runtime

Using the "dotnet:2.1-aspnetcore-runtime" image solves the problem. 使用“ dotnet:2.1-aspnetcore-runtime”映像可以解决该问题。 I can only assume there is something wrong with the "microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine3.7" image. 我只能假定“ microsoft / dotnet:2.1.1-aspnetcore-runtime-alpine3.7”映像出了问题。

As a side effect of this switch, my docker image is larger. 作为此开关的副作用,我的docker映像更大。 Previously my docker image was 71mb, but with this change, it is now 107mb. 以前,我的docker映像为71mb,但经过这次更改,现在为107mb。 I'm okay with that. 我可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM