[英]Request hangs for nginx reverse proxy to an ASP.NET 5 web application on docker
I am trying to get nginx, ASP.NET 5, Docker and Docker Compose working together on my development environment but I cannot see it working so far. 我试图让nginx,ASP.NET 5,Docker和Docker Compose在我的开发环境中一起工作,但到目前为止我看不到它的工作原理。 This is the state where I am now and let me briefly explain here as well. 这是我现在的状态,让我在这里简要解释一下。
I have the following docker-compose.yml file: 我有以下docker-compose.yml文件:
webapp:
build: .
dockerfile: docker-webapp.dockerfile
container_name: hasample_webapp
ports:
- "5090:5090"
nginx:
build: .
dockerfile: docker-nginx.dockerfile
container_name: hasample_nginx
ports:
- "5000:80"
links:
- webapp:webapp
docker-nginx.dockerfile
file: docker-nginx.dockerfile
文件:
FROM nginx
COPY ./nginx.conf /etc/nginx/nginx.conf
and docker-webapp.dockerfile
file: 和docker-webapp.dockerfile
文件:
FROM microsoft/aspnet:1.0.0-rc1-update1
COPY ./WebApp/project.json /app/WebApp/
COPY ./NuGet.Config /app/
COPY ./global.json /app/
WORKDIR /app/WebApp
RUN ["dnu", "restore"]
ADD ./WebApp /app/WebApp/
EXPOSE 5090
ENTRYPOINT ["dnx", "run"]
nginx.conf
file: nginx.conf
文件:
worker_processes 4;
events { worker_connections 1024; }
http {
upstream web-app {
server webapp:5090;
}
server {
listen 80;
location / {
proxy_pass http://web-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
All good and when I run docker-compose up
, it gets two containers up and running which is also nice. 一切都很好,当我运行docker-compose up
,它会启动并运行两个容器,这也很不错。 From the host, when I hit localhost:5000
, the request just hangs and when I terminate the request, nginx writes out a log through docker compose indicating 499
HTTP response. 从主机,当我点击localhost:5000
,请求只是挂起,当我终止请求时,nginx通过docker compose写出一个日志,指示499
HTTP响应。
Any idea what I might be missing here? 知道我在这里可能缺少什么吗?
I added some logging to ASP.NET 5 app and when I hit localhost:5000, I can verify that request is being send to ASP.NET 5 but it's
being terminated immediately
giving a healthy response judging from the 200 response. 我在ASP.NET 5应用程序中添加了一些日志记录,当我点击localhost:5000时,我可以验证请求是否正在发送到ASP.NET 5,但它
会立即终止,
从200响应中判断出健康的响应。 Then, nginx sits on it util I terminate the request through the client. 然后,nginx坐在它上面我通过客户端终止请求。
This is a known bug in Kestrel RC1: https://github.com/aspnet/KestrelHttpServer/issues/341 这是Kestrel RC1中的已知错误: https : //github.com/aspnet/KestrelHttpServer/issues/341
You can work around it by forcing Connection: keep-alive
: 你可以通过强制Connection: keep-alive
来解决它Connection: keep-alive
:
proxy_set_header Connection keep-alive;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.