Default nginx-proxy container for mapping hostname to correct Docker application container.
-
On your host (web) server, clone pmg-docker-ngnix-proxy into your web root.
-
Navigate into
pmg-docker-nginx-proxy. -
Run
docker network create front. -
Run
docker-compose up -d --build. -
Following the nginx-proxy example docker-compose.yml, add the code to your application's Docker Compose file.
-
Define the ports to avoid collisions with other applications, making sure to map to the default port. e.g.
services: web: image: web environment: VIRTUAL_HOST: mysite.com ports: - "8080:80"
-
Define the following network your application's Docker Compose file (at the bottom of the file, outside of
services):networks: front: external: true
-
Use the front network on the desired services by adding:
```yml
networks:
- front
```
e.g.
```yml
services:
web:
image: web
container_name: web
networks:
- front
```
- Commit, push, and pull on your host (web) server.
- Run
docker-compose up -d --buildor a custom build script.
To secure your virtual host, create a htpasswd file named as its equivalent VIRTUAL_HOST variable in config/htpasswd.
For example, if you have VIRTUAL_HOST: more.cool.com, create a htpasswd file at config/htpasswd/more.cool.com.