Request hangs for nginx reverse proxy to an ASP.NET 5 web application on docker
<p>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. <a href="https://github.com/tugberkugurlu/aspnet-5-samples/tree/e661f45a684f9acf329792c65c511f21ac496437/HASample" rel="nofollow noreferrer">This</a> is the state where I am now and let me briefly explain here as well.</p>

<p>I have the following docker-compose.yml file:</p>

<pre><code>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
</code></pre>

<p><code>docker-nginx.dockerfile</code> file:</p>

<pre><code>FROM nginx
COPY ./nginx.conf /etc/nginx/nginx.conf
</code></pre>

<p>and <code>docker-webapp.dockerfile</code> file:</p>

<pre><code>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"]
</code></pre>

<p><code>nginx.conf</code> file:</p>

<pre><code>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;
      }
    }
}
</code></pre>

<p>All good and when I run <code>docker-compose up</code>, it gets two containers up and running which is also nice. From the host, when I hit <code>localhost:5000</code>, the request just hangs and when I terminate the request, nginx writes out a log through docker compose indicating <code>499</code> HTTP response.</p>

<p>Any idea what I might be missing here?</p>

<h2>Update:</h2>

<p>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 <strike>being terminated immediately</strike> giving a healthy response judging from the 200 response. Then, nginx sits on it util I terminate the request through the client.</p>

<p><a href="https://i.stack.imgur.com/pLyhH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pLyhH.png" alt="enter image description here"></a></p>