Requirement
- docker desktop
- basic knowledge of how docker works
Getting Started
What is nginx reverse proxy ?
- nginx reverse proxy can be simplified as client is accessing the site via nginx acting as the middleware between client and site
What is the benefit ?
- you can have multiple site under 1 nginx middleware
How to get started ?
- Create a new docker-compose.yml file
- Content of the docker-compose.yml
version: '3.7'
services:
proxy:
image: jwilder/nginx-proxy
container_name: proxy-test
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
container1:
image: httpd:2.4
container_name: container-1
environment:
- VIRTUAL_HOST:container1.com
ports:
- 8080:80
container2:
image: httpd:2.4
container_name: container-2
environment:
- VIRTUAL_HOST:container2.com
ports:
- 8081:80
- after you have filled in the docker-compose.yml with the code above, save and run the file by using command
docker-compose up -d
- You can access the container by opening localhost:
<port>
, for this example it is running on localhost:8080 and localhost:8081
Conclusion
- As my writing has reached it's end, i would like to say thank you for reading this article and have a try playing around with nginx reverse proxy, maybe it will give you more ideas on how to manage your site deployment
Top comments (0)