I'm trying to make an application with about the following functionality:
when the user enters 1234.my.domain.com, he should see the small django-application response that is in the container with port 1234.
On my server, I have nginx(on the server, not in container!) with the configuration for my task:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# This captures the subdomain (if digits) as the $backport variable
server_name ~^(?P<backport>[0-9]+)\.my\.domain\.com$;
location / {
resolver 127.0.0.11 ipv6=off;
if ($backport) {
proxy_pass http://localhost:$backport;
}
}
}
and docker-compose.yml
version: '3'
services:
db:
image: postgres
web:
build: .
command: python3.6 manage.py runserver 0.0.0.0:8080
container_name: "task_${TASK_ID}"
volumes:
- .:/code
ports:
- "${TASK_ID}:8080"
depends_on:
- db
When I write docker-compose up, everything runs fine and when i write curl localhost:1234, i see django hello-world html code.
But when I type in the browser 1234.my.domain.com, I get 502 Bad Gateway.
In nginx error log i see
recv() failed (111: Connection refused) while resolving, resolver: 127.0.0.11:53
I googled a lot, but I did not find a solution to the problem. Maybe I'm missing something, but for me it's very strange that nginx can not connect to docker dns. It looks like a docker problem
Output of "docker-compose version"
docker-compose version 1.21.0, build 5920eb0
docker-py version: 3.2.1
CPython version: 3.6.5
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
Output of "docker version"
Client:
Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:56 2018
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.1-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:16:28 2018
OS/Arch: linux/amd64
Experimental: false
Please use the forums for support.
@yarkaktus Have you been able to solve the issue? If so, then how? Facing the same problem in GKE kubernetes cluster. Thank you for any kind of help.