c# - 502 Bad Gateway nginx/1.14.1 elasticbeanstalk

我有 .net 核心应用程序在 docker 中运行,当我将图像部署到 amazon Elastic Beanstalk 时,状态正常,但是当我尝试访问该页面时,我收到“502 Bad Gateway nginx/1.14.1”

Docker文件:

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR  /src
COPY ["MyApp.csproj", "."]
RUN dotnet restore "MyApp.csproj"
COPY . .
RUN dotnet build "MyApp.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app

FROM base AS final
WORKDIR . /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyApp.dll"]

Dockerrun.aws.json

{
"AWSEBDockerrunVersion": "1",
  "Image": {
"Name": "xxxx/myapp",
"Update": "true"
},
"Ports": [
{
  "ContainerPort": "80"
}
 ]
}

日志:

2019/07/16 10:55:34 [error] 13553#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 185.32.153.2, server: , request: "GET / HTTP/1.1", upstream: "http://172.17.0.3:80/", host: "myapp-env11.us-east-1.elasticbeanstalk.com"

我应该打开什么端 Eloquent 能运行?

最佳答案

所以我今天早些时候遇到了同样的问题。事实证明这是我的应用程序无法启动的问题,nginx 无法访问它。

在查看日志之后。我发现这是一个连接字符串问题,因为我的应用程序是在本地启动的,当我部署到 IIS 而不是部署到 AWS elastic-beanstalk 时。

我的应用程序不是 dockerized 应用程序,但同样的问题几乎让我度过了糟糕的一天。

因此,这是我的建议,下载您的日志并查看日志中是否存在任何特定于应用程序的错误,在我的情况下,我必须检查 web.stdout 日志。

所以我解决了我的连接字符串问题。

来自:

"DefaultConnection": "Server=dbserverURL,1433;Database=DbName;User Id=dbuser;Password=dbPass;Trusted_Connection=True;MultipleActiveResultSets=true"

收件人:

"DefaultConnection": "Server=dbserverURL,1433;Database=DbName;Integrated Security=false;User Id=dbuser;Password=dbPass;MultipleActiveResultSets=true"

关于c# - 502 Bad Gateway nginx/1.14.1 elasticbeanstalk .net 核心应用程序在 docker 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57056187/

相关文章:

c# - C# 中 C++ 结构化绑定(bind)的模拟

jenkins - BlueOcean编辑器 "scm"输入什么

flutter - 如何修复 flutter 上的 "A RenderFlex overflowed

reactjs - 如何使用 Jest 和 Enzyme 在 nextjs 应用程序中编写单元测试

angular - Mat-select 滚动不跳转到选定的 mat-option

reactjs - 在 nextjs 中,对象类型从服务器端更改为客户端

amazon-web-services - 如何在数据加载前截断 AWS Glue 作业中的 RDS

android - react native : compileDebugJavaWithJavac

spring-boot - spring boot 微服务 docker 实现中 google oa

reactjs - Babel 不从当前目录上方的文件转译 JSX