Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx fail on Docker deployment to Amazon

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;
}
like image 282
Fishman Avatar asked Dec 14 '22 10:12

Fishman


1 Answers

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.

like image 183
Richard Smith Avatar answered Jan 04 '23 08:01

Richard Smith