-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.traefik.yml
45 lines (43 loc) · 1.79 KB
/
docker-compose.traefik.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Creates an nginx, proxied by traefik on port 8080, with caching disabled using Cache-Control HTTP headers. This is useful when working behind a reverse proxy, e.g. cloudflare.
version: '2.2'
services:
web:
image: nginx:1.14-alpine
# Enable labels for traefik
labels:
# traefik v2
- "traefik.enable=true"
- 'project.name=${COMPOSE_PROJECT_NAME}' # Constraint for traefik
# - "traefik.docker.network=${COMPOSE_PROJECT_NAME}_default" # Override the network that traefik should use
- "traefik.http.services.web.loadbalancer.server.port=80"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.routers.web.rule=HostRegexp(`{catchall:.*}`)"
# - "traefik.http.routers.web.rule=PathPrefix(`/`)"
- "traefik.http.routers.web.middlewares=nocache"
- "traefik.http.middlewares.nocache.headers.customResponseHeaders.Cache-Control=private, no-cache, no-store, must-revalidate, max-age=0, s-maxage=0"
- "traefik.http.middlewares.nocache.headers.customResponseHeaders.Pragma=no-cache"
networks:
# The default '${COMPOSE_PROJECT_NAME}_default' network
- default
volumes:
- .:/usr/share/nginx/html:ro
# Run traefik v2 on port 8080
traefik-v2:
image: traefik:v2.4
command:
# - --log.level=DEBUG
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.constraints=Label(`project.name`,`${COMPOSE_PROJECT_NAME}`)
- --entrypoints.web.address=:80
networks:
# The default '${COMPOSE_PROJECT_NAME}_default' network
- default
ports:
- 8080:80
volumes:
# Allow traefik to listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
# The default '${COMPOSE_PROJECT_NAME}_default' network
default: