I have a fresh Droplet on Ubuntu 16.04 running Docker and Docker Compose with two containers: nginx and my homepage.
My homepage container is running on port 3000. I can curl localhost:3000 and see the app.
I have this setup on my home server and on AWS and the proxy_pass
value is the local/private IP address of my server. For example on my home server it’s http://192.168.1.100:3000/
, on AWS it’s the Private IP of the EC2 instance.
I have tried several values on the Droplet for proxy_pass
such as http://127.0.0.1:3000
, localhost
, but none of those worked. I lastly tried enabling private networking and tried using the listed private IP address. Still nothing…
What should I be using for the value here?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
My apologies if this is against the rules to post an answer to your own question, but many times in the past I’d wished others had done the same.
For those that weren’t aware, whenever you use
docker-compose up
, it automatically creates a default docker network if you don’t specify any in the docker-compose.yaml. Docker containers in the same network automatically get a DNS entry created for the container name. That means you can access the other containers in the network using something likehttp://mycontainername:8080
.For the Nginx container running the reverse proxy, the
proxy_pass
value ended up just beinghttp://myapp:3000
.Definitely seems like a no-brainer. I know I had seen posts online regarding using a name url like that but was ignoring all them because I didn’t realize the docker network was doing that behind the scenes and din’t put it together that using the container name would work in this way.
Hopefully this helps someone!