我有 .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/