If you have multiple services running on Docker with different ports, you have to open ports in your firewall and you have to access the services via different ports in the browser. To have one access port (port 80 or 443) you can use a reverse proxy.
In our case we used NGINX to redirect the access to Kibana (Elasticsearch Dashboard Tool) and PgAdmin4 (PostgreSQL Admin Tool) so that we can access both services on the same port (80) in the browser with different base paths: http://localhost/kibana and http://localhost/pgadmin.
docker-compose.yml:
version: '3.0'
services:
elasticsearch:
hostname: elasticsearch
image: elasticsearch:7.5.0
ports:
- 9200:9200
- 9300:9300
volumes:
- esdata:/usr/share/elasticsearch/data
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
kibana:
hostname: kibana
image: kibana:7.5.0
depends_on:
- elasticsearch
environment:
- XPACK_MONITORING_ENABLED=false
- LOGGING_QUIET=true
- SERVER_BASEPATH=/kibana
- SERVER_REWRITEBASEPATH=true
postgres:
hostname: postgres
image: postgres:12.1
ports:
- 5432:5432
volumes:
- postgresdb:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=manager
pgadmin:
hostname: pgadmin
image: dpage/pgadmin4
volumes:
- pgadmin:/var/lib/pgadmin
environment:
- PGADMIN_DEFAULT_EMAIL=postgres
- PGADMIN_DEFAULT_PASSWORD=manager
- GUNICORN_ACCESS_LOGFILE=/dev/null
proxy:
hostname: proxy
image: nginx:1.17.8
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- kibana
- pgadmin
volumes:
esdata:
postgresdb:
pgadmin:
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
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 /dev/null;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
root /var/www;
index index.html;
location / {
try_files $uri $uri/ =404;
}
location /pgadmin {
proxy_pass http://pgadmin/;
proxy_http_version 1.1;
proxy_set_header X-Script-Name /pgadmin;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /kibana {
proxy_pass http://kibana:5601/kibana;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}