Einsteinish / Docker-compose-Nginx-Reverse-Proxy

38 stars 60 forks source link

Make docker-compose work #4

Closed tsauvajon closed 3 years ago

tsauvajon commented 3 years ago

Before this PR:

In one terminal:

$ docker-compose run reverseproxy

In another terminal:

$ curl http://127.0.0.1:8081
curl: (7) Failed to connect to 127.0.0.1 port 8081: Connection refused

This is because the entry command of the reverseproxy container is bash, so it won't run nginx at all.

Also, docker-compose up exits immediately (since it's starting with a non-interactive bash CMD).


With this PR, both docker-compose up and docker-compose run reverseproxy yield the expected results:

$ curl http://127.0.0.1:8081
<html><body><h1>It works!</h1></body></html>

$ curl http://127.0.0.1:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...

A note for depends_on: reverse proxy depends on the other two services (it cannot run by itself, otherwise it routes to nothing). Apache and Nginx can run perfectly well on their own, they don't depend on the reverse proxy.

tsauvajon commented 3 years ago

Closing because of inactivity, I still think it makes sense to merge if you see this