4

I am trying to deploy .net asp web api application in Docker container to Amazon via elasticbeanstalk, but here is what I got:

ERROR: Failed to start nginx, abort deployment
ERROR: [Instance: i-ecf0d365] Command failed on instance. Return code: 1 Output: nginx: [emerg] invalid host in upstream "172.17.0.2:5000/tcp" in /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

Image is here: https://hub.docker.com/r/wedkarz/awsm8-api/

Dockerfile

FROM microsoft/aspnet:latest

COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]

EXPOSE 5000/tcp
ENTRYPOINT ["dnx", "-p", "project.json", "web"]

elasticbeanstalk-nginx-docker-upstream.conf file

upstream docker {
    server 172.17.0.2:5000/tcp;
    keepalive 256;
}
Fishman
  • 1,737
  • 1
  • 25
  • 42
  • Error message suggests that you have a spurious `/tcp` in your `nginx` configuration file, either on an `upstream server` directive or an `xxx_pass` directive. – Richard Smith Dec 10 '15 at 22:39
  • I have updated question with conf file? Where this nginx configuration came from? was it included in aspnet image? or docker put this for whatever reason? – Fishman Dec 10 '15 at 22:50
  • I don't know, but it seems to have used `5000/tcp` as the port, rather than the correct value which should be `5000`. – Richard Smith Dec 10 '15 at 22:57
  • @RichardSmith you were right! I changed Dockerfile to EXPOSE 5000 and now it works :) – Fishman Dec 11 '15 at 18:23
  • @RichardSmith nice catch. can you please submit this as the formal answer? – Tal Dec 11 '15 at 19:38

1 Answers1

12

The error message nginx: [emerg] invalid host in upstream "172.17.0.2:5000/tcp" shows an upstream server parameter with the spurious characters /tcp following the port number. See upstream module documentation.

@Fishman confirmed that the erroneous parameter appeared within the nginx configuration file, and that this file was generated from the Dockerfile, and that the problem was corrected by changing the value of the EXPOSE parameter (within the Dockerfile) from 5000/tcp to 5000.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81