I felt into issues configuring environment, containing postgres, pgadmin and nginx. All this services are in docker containers and here is my docker-compose file:
version: '3'
services:
postgres:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
pgadmin:
links:
- postgres:postgres
image: dpage/pgadmin4:3.0
environment:
PGADMIN_DEFAULT_EMAIL: '[email protected]'
PGADMIN_DEFAULT_PASSWORD: 'postgres'
ports:
- "5050:80"
restart: unless-stopped
nginx:
links:
- pgadmin:pgadmin
image: "nginx:1.13.12"
ports:
- "80:80"
volumes:
- ./nginxServers/server:/etc/nginx/conf.d/default.conf
And here is my nginx.conf, placed in ./nginxServers/server:
server {
listen 80;
server_name _;
location /pgadmin/ {
proxy_pass http://pgadmin/;
}
}
As you can see, it's a very simple setup, allowing me to use pgadmin via http://localhost/pgadmin.
Unfortunately, this doesn't work. I can see pgadmin web interface via http://127.0.0.1:5050, but when i navigate to http://127.0.0.1/pgadmin, all the styles and scripts are not loaded.
I also tried another location in nginx configuration:
location /pgadmin {
proxy_pass http://pgadmin;
}
But this also didn't help.
Thus, i'm stucked with correct configuration of nginx as a reverse proxy for pgadmin.
P.S. As i've googled, this problem can be with serving django static content, but since i'm not familiar with django, i can't get any workaround.
I'll be gratefull for any help with this strange problem.
docker network? - Alejandro Galeranetwork: hostfor docker-compose, or if you launch it with docker,docker run --net=host...- Alejandro Galeranetwork_mode: "host"and now it doesn't work at all, because nginx can't find hostname pgadmin. What did you want me to do withnet=host? I'm not very good with docker-compose yet - Alex Voskresenskiydocker run --net=hostoption, container inherits all network configuration of the host. So, is possible to share eth interfaces, including localhost. In docker-compose, section is called:network-mode: "host". Let me post in an answer, so you can see better structured the code. - Alejandro Galera