I'm trying to setup a local env using Nginx container as reverse proxy to Jfrog container and Gitlab (with Nginx build in enabled) container, I can access the artifactory container through the Nginx (reverse proxy) but when I'm trying to access the Gitlab container through the Nginx (revrese proxy) I get Connection Refused error.
Here is my Nginx configuration:
upstream gitlab {
server git.dev.local:8000;
}
upstream jfrog {
server jfrog.dev.local:8082;
}
server {
server_name git.dev.local;
location / {
proxy_pass http://gitlab;
}
}
server {
server_name jfrog.dev.local;
location / {
proxy_pass http://jfrog;
}
}
Notes:
set Gitlab exteranl_url to "git.dev.local".
I can access the git.dev.local:8000
directly without any issues.
the jfrog mapped from port 8082 to 8082 and gitlab from 8000 to 80.
the Jfrog is accessible using the nginx reverse proxy without any issues.
the Nginx (reverse proxy), Gitlab and Jfrog containers all attached to custom network with their host names.
docker network connect --alias jfrog.dev.local general-network jfrog
docker network connect --alias git.dev.local general-network gitlab
[error] 42 42: *111 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.48.1, server: git.dev.local, request: "GET /api HTTP/1.1", upstream: "http://172.18.0.2:8000/", host: "git.dev.local"
When doing reverse proxy using nginx container, I should forward the port to the docker port not host port as the answered here. thanks for Jollege answer.