miércoles, 23 de enero de 2019

nginx: [emerg] host not found in upstream "nodejs" enabling TLS in AWS EB

Error:

2019-01-23 22:44:55    ERROR   [Instance: i-xx] Command failed on instance. Return code: 1 Output: (TRUNCATED)... /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
nginx: [emerg] host not found in upstream "nodejs" in /etc/nginx/conf.d/https.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed
Failed to start nginx, abort deployment.
Hook /opt/elasticbeanstalk/hooks/appdeploy/enact/01flip.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

I was using a .ebextensions/singlehttps.config sample file from a Node Web Server Elastic Beanstalk app, with something like this,

location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;

but no upstream declaration because according AWS doc, "the default nginx configuration forwards traffic to an upstream server named nodejs at 127.0.0.1:8081".

But this App is a docker one (which has a Node app running on port 3500), not a nodejs one.

Looking at the EB instance's /etc/nginx/conf.d dir, this file declares a default upstream for docker:

elasticbeanstalk-nginx-docker-upstream.conf:

upstream docker {
    server xx.xx.x.x:yyy;
    keepalive 256;
}

Then,


location / {
proxy_pass http://docker;
proxy_set_header Connection "";
proxy_http_version 1.1;


No hay comentarios: