I am facing this issues I am not able to solve by anything I´ve found on this site or anywhere else.
Lets assume I have a domain and Debian server with NGINX installed on it as main gateway for web server. On this domain (on root level) I have a traditional handling (like strippping www, redirecting everytime to https etc - basic stuff).
But now I´d like to have a set of services managed in docker-compose
file that will be executed on docker start and these services will be mapped as subdomains to my main domain. Lets assume that domain has set up proper DNS records (these are not problem since I´ve been using subdomains for non docker services with no issues). For simplity take just one service- pgAdmin4
- as example
Part of the NGINX configuration that solves this issue is pretty basic.
server {
listen 80;
server_name pg.example.com;
location / {
proxy_pass http://pgadmin:81;
}
}
Docker compose is even more basic
version: '3.8'
services:
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: pw
ports:
- "81:80"
When I try to sudo nginx -t
to check the configuration, I am getting an error host not found in upstream "pgadmin"
When I try to replace name of container with host.docker.internal
(with extra_hosts in compose set up like "host.docker.internal:host-gateway"
) or when I try to use 127.0.0.1:81
or simply localhost:81
, I am getting (after restarting NGINX) 502 Bad Gateway
whitelabel page error.
In logs I can see a lot of errors like
*2 no live upstreams while connecting to upstream, client: 78.136.141.1, server: pg.example.com, request: "GET / HTTP/1.1", upstream: "http://localhost/", host: "pg.example.com"
Can anyone tell me what am I doing wrong?