Symfony Docker dotnet core nginx代理502
我需要使用dotnetcore和nginx代理服务器。我有两个简单的图像和docker compose文件。Dotnet应用程序使用正确的端口运行良好。但当我将它与nginx一起使用时,我认为它是映射到80的。Nginx抛出错误502 我的步骤:Symfony Docker dotnet core nginx代理502,symfony,nginx,docker,proxy,.net-core,Symfony,Nginx,Docker,Proxy,.net Core,我需要使用dotnetcore和nginx代理服务器。我有两个简单的图像和docker compose文件。Dotnet应用程序使用正确的端口运行良好。但当我将它与nginx一起使用时,我认为它是映射到80的。Nginx抛出错误502 我的步骤: 从以下位置创建docker compose文件: 使用:docker build--no cache=true-t dotnetcoreimage创建dotnet应用程序映像 码头工人整理 以下是我的应用程序设置: { "iisSettings":
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://*:5000/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express (Production)": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}
}
应用程序Docker文件:
# FROM microsoft/dotnet:latest
FROM microsoft/aspnetcore-build
#Update everytihing
RUN apt-get -qq update && apt-get -qq -y install bzip2
#remove force apt lists
RUN rm -rf /var/lib/apt/lists/*
#for secure, copy to app folder
COPY . /app
RUN rm -Rf /app/node_modules
RUN rm -Rf /app/bower_components
#set workdir
WORKDIR /app
#set ASPNETCORE_ENVIRONMENT to Production
ENV ASPNETCORE_ENVIRONMENT "Production"
#restore packages
RUN ["dotnet", "restore"]
#build c#
RUN ["dotnet", "build"]
#npm install dependencies (webpack etc.)
RUN ["npm", "install"]
#run npm task webpack-prod
RUN ["npm", "run", "webpack-prod"]
EXPOSE 5000/tcp
# command to run
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]
docker compose.yml
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
mujcykloweb:
image: mujcykloweb
container_name: mujcyklowebcontainer
environment:
- VIRTUAL_HOST=localhost
运行时:docker撰写并转到
我认为,那个web应用程序的端口映射不好,因为80是否应该有nginx?(现在收听:)
我尝试了docker Compositive——强制重新创建、停止/启动docker并重新启动pc,但同样的问题
请问问题在哪里?
感谢您抽出时间。Dockerfile公开5000端口和应用程序侦听5000端口。好的
EXPOSE 5000/tcp CMD[“dotnet”,“run”,“--server.url”,“http://*:5000”]
但为什么您在什么时候运行应用程序it listen 80端口mujcyklowebcontainer |现在收听:http://+:80
我很困惑。谢谢你的回答。我也很困惑,因为没有编写,只有dotnet运行正确的列表端口。也许是docker的缓存?我不知道。让我们尝试向docker comose公开应用程序端口。尝试添加mujcykloweb:port:-5000:5000
您有权访问http://localhost:5000
来自主机?不,我得到:加载资源失败:我的浏览器中出现net::ERR\u EMPTY\u响应。嗯,有人正在监听5000端口。可能是你的应用程序?你的应用程序有访问日志吗?当您公开5000端口时,请让我们尝试通过nginx访问您的应用程序。
Creating network "cykloweb_default" with the default driver
Creating nginx-proxy
Creating mujcyklowebcontainer
Attaching to mujcyklowebcontainer, nginx-proxy
nginx-proxy | forego | starting nginx.1 on port 5000
nginx-proxy | forego | starting dockergen.1 on port 5100
nginx-proxy | dockergen.1 | 2017/01/14 16:16:36 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
nginx-proxy | dockergen.1 | 2017/01/14 16:16:36 Running 'nginx -s reload'
nginx-proxy | dockergen.1 | 2017/01/14 16:16:36 Watching docker events
nginx-proxy | dockergen.1 | 2017/01/14 16:16:36 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
mujcyklowebcontainer | Project app (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
mujcyklowebcontainer | Running Environment: Production
mujcyklowebcontainer | info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
mujcyklowebcontainer | User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
mujcyklowebcontainer | Hosting environment: Production
mujcyklowebcontainer | Content root path: /app
mujcyklowebcontainer | Now listening on: http://+:80
mujcyklowebcontainer | Application started. Press Ctrl+C to shut down.
nginx-proxy | nginx.1 | 2017/01/14 16:16:58 [error] 25#25: *1 no live upstreams while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://334389048b872a533002b34d73f8c29fd09efc50/", host: "localhost:5050"
nginx-proxy | nginx.1 | localhost 172.19.0.1 - - [14/Jan/2017:16:16:58 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
nginx-proxy | nginx.1 | localhost 172.19.0.1 - - [14/Jan/2017:16:16:58 +0000] "GET /favicon.ico HTTP/1.1" 502 575 "http://localhost:5050/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
nginx-proxy | nginx.1 | 2017/01/14 16:16:58 [error] 25#25: *1 no live upstreams while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://334389048b872a533002b34d73f8c29fd09efc50/favicon.ico", host: "localhost:5050", referrer: "http://localhost:5050/"
nginx-proxy | nginx.1 | 2017/01/14 16:17:32 [error] 25#25: *1 no live upstreams while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://334389048b872a533002b34d73f8c29fd09efc50/", host: "localhost:5050"
nginx-proxy | nginx.1 | localhost 172.19.0.1 - - [14/Jan/2017:16:17:32 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
nginx-proxy | nginx.1 | 2017/01/14 16:17:32 [error] 25#25: *1 no live upstreams while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://334389048b872a533002b34d73f8c29fd09efc50/favicon.ico", host: "localhost:5050", referrer: "http://localhost:5050/"
nginx-proxy | nginx.1 | localhost 172.19.0.1 - - [14/Jan/2017:16:17:32 +0000] "GET /favicon.ico HTTP/1.1" 502 575 "http://localhost:5050/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"