nginx-container

Best way to expose services to be accessed outside is through proxy (like nginx). Without exposing any ports to the host machine, only expose nginx port and access all services needed using the nguni port using different URI.

Nginx will fail to start if the downstream system is down, to overcome use a variable to set the service name and use the said variable in the proxy_pass.

While proxying to services, docker DNS should be specified, else the URL will not be resolved. Default DNS resolver for docker is 127.0.0.11.

Sample myproxy.conf

server {

listen 9119;

resolver 127.0.0.11 valid=30s;

client_max_body_size 1G;

location /grafana/ {

set $upstream sift-grafana:3000/;

proxy_pass http://$upstream;

}

location /kibana/ {

set $upstream sift-kibana:5601/;

proxy_pass http://$upstream;

}

}

Link - https://sandro-keil.de/blog/let-nginx-start-if-upstream-host-is-unavailable-or-down/