1
I have a stack with Docker-swarm with about 80 containers that when I need to recreate the whole takes more than an hour to go up completely because NGINX keeps giving alerts and trying to make the connection with the containers with the error below:
2019/04/25 10:12:55 [emerg] 4246#4246: host not found in upstream "prd_teste_cliente" in /etc/nginx/upstreams/upstream_prd_teste_cliente.conf:3
ftc-ed_nginx.1.unqyfjytn6r3@edworker01 | nginx: [emerg] host not found in upstream "prd_teste_cliente" in /etc/nginx/upstreams/upstream_prd_teste_cliente.conf:3
The upstream file is like this:
upstream prd_teste_cliente {
least_conn;
server prd_teste_cliente max_fails=1 fail_timeout=60 weight=1 max_conns=100;
}
The Nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server_names_hash_max_size 512;
server_names_hash_bucket_size 128;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 256m;
keepalive_timeout 0;
#gzip on;
# Enable Cache Support
proxy_cache_path /data/nginx/cache/app levels=1:2 keys_zone=app:10m max_size=2g inactive=60m use_temp_path=off;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
proxy_connect_timeout 300000;
proxy_send_timeout 300000;
proxy_read_timeout 300000;
send_timeout 300000;
include /etc/nginx/conf.d/*.conf;
server {
listen 8081;
server_name 10.0.213.5;
large_client_header_buffers 4 128k;
location / {
stub_status;
}
location /server_status {
stub_status;
}
}
}
File Location:
server {
listen 80;
server_name cliente.teste.com.br;
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_types text/plain text/css text/javascript application/x-javascript text/xml application/xml;
gzip_min_length 1400;
server_tokens off;
add_header X-Content-Type-Options nosniff;
proxy_hide_header X-Powered-By;
client_header_timeout 5s;
client_body_timeout 5s;
location / {
proxy_pass http://prd_teste_cliente;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 600000;
proxy_send_timeout 600000;
proxy_read_timeout 600000;
send_timeout 600000;
}
}