mirror of
https://github.com/thib8956/nginx-proxy
synced 2024-11-24 21:06:31 +00:00
Add docker-compose.yml v2 example
This commit is contained in:
parent
b325dad98d
commit
fdf93cafba
26
README.md
26
README.md
@ -19,6 +19,32 @@ The containers being proxied must [expose](https://docs.docker.com/reference/run
|
||||
|
||||
Provided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
container_name: nginx-proxy
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
whoami:
|
||||
image: jwilder/whoami
|
||||
container_name: whoami
|
||||
environment:
|
||||
- VIRTUAL_HOST=whoami.local
|
||||
```
|
||||
|
||||
```shell
|
||||
$ docker-compose up
|
||||
$ curl -H "Host: whoami.local" localhost
|
||||
I''m 5b129ab83266
|
||||
```
|
||||
|
||||
### Multiple Ports
|
||||
|
||||
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.
|
||||
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
container_name: nginx-proxy
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
whoami:
|
||||
image: jwilder/whoami
|
||||
environment:
|
||||
- VIRTUAL_HOST=whoami.local
|
||||
|
Loading…
Reference in New Issue
Block a user