Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem - error 404 #15

Open
douglasoliveiraadv opened this issue Jan 30, 2019 · 1 comment
Open

Problem - error 404 #15

douglasoliveiraadv opened this issue Jan 30, 2019 · 1 comment

Comments

@douglasoliveiraadv
Copy link

Hi,
I execute the following commands:

docker run -d -p 80:80 -v /var/run/docker.sock:/docker.sock --name dns \

phensley/docker-dns-rest --verbose 

curl -X PUT -H 'Content-Type: application/json' \

-d '{"domains": ["payserver1.mps.portalmenew.com.br"]}' \
http://172.17.0.2:80/container/name/payserver1

docker run -it --name payserver1 payserver

docker logs dns

2019-01-30T15:54:19.784346 [dnsrest] added payserver1.mps.portalmenew.com.br. -> 172.17.0.3 key=name:/payserver1

curl -I payserver1.mps.portalmenew.com.br

HTTP/1.1 404 Not Found
content-type: application/json; charset=UTF-8
Date: Wed, 30 Jan 2019 16:00:56 GMT
Content-Length: 0

Ps... In this payserver1 I have Apache

But it does not work.
Can you help me?!
thank you!

@phensley
Copy link
Owner

The problem with your last command is your curl is not using the "dns" container for DNS resolution, so you'll need a version that supports the --dns-servers option. I retraced your steps below:

Start DNS Service:

$ docker run -d -p 5080:80 -v /var/run/docker.sock:/docker.sock --name dns phensley/docker-dns-rest --verbose
8824e1255c4f1afe3a9315aab1c4ada3bd99e8ebc8b6a0e47cb1bb9a262a89c1

$ curl -X PUT -H 'Content-Type: application/json' -d '{"domains": ["payserver1.mps.portalmenew.com.br"]}' http://127.0.0.1:5080/container/name/payserver1
{"code": 0}

$ docker inspect -f '{{.NetworkSettings.IPAddress}}' dns
172.17.0.8

$ docker logs -f dns
2019-01-31T22:56:39.918832 [dnsrest] added payserver1.mps.portalmenew.com.br. -> 172.17.0.7 key=name:/payserver1

Start a web service container:

$ docker run -it --rm --name payserver1 python python -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

$ docker inspect -f '{{.NetworkSettings.IPAddress}}' payserver1
172.17.0.7

Ping the "payserver1" container from inside Docker, using "dns" container as the resolver:

$ docker run -it --rm --name sh --dns 172.17.0.8 alpine /bin/sh
/ # ping payserver1.mps.portalmenew.com.br
PING payserver1.mps.portalmenew.com.br (172.17.0.7): 56 data bytes
64 bytes from 172.17.0.7: seq=0 ttl=64 time=0.190 ms
..

Make an HTTP request to the "payserver1" container from outside of Docker. This requires your DNS queries be sent to the "dns" container, which can be done with curl --dns-servers.

To demonstrate I built the latest version of curl and got a successful result:

 $ sudo apt install libc-ares-dev
 $ wget https://github.com/curl/curl/releases/download/curl-7_63_0/curl-7.63.0.tar.xz
 $ tar xf curl-7.63.0.tar.xz
 $ ./configure --enable-ares
 $ make -j 64

 $ ./src/curl -v -o /dev/null --dns-servers 172.17.0.8 http://payserver1.mps.portalmenew.com.br/
 * TCP_NODELAY set
 * Connected to payserver1.mps.portalmenew.com.br (172.17.0.7) port 80 (#0)
 > GET / HTTP/1.1
 > Host: payserver1.mps.portalmenew.com.br
 > User-Agent: curl/7.63.0
 > Accept: */*
 >
 * HTTP 1.0, assume close after body
 < HTTP/1.0 200 OK
 < Server: SimpleHTTP/0.6 Python/3.7.2
 < Date: Thu, 31 Jan 2019 23:09:22 GMT
 < Content-type: text/html; charset=utf-8
 < Content-Length: 987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants