Last active
January 26, 2021 15:38
-
-
Save emadpres/e21c09f56829fa7a84ebf78ed7ad4fe1 to your computer and use it in GitHub Desktop.
Reverse Proxy with traefik + docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
# Maintainer: Emad Aghajani | |
# Source and guideline: https://gist.github.com/emadpres/e21c09f56829fa7a84ebf78ed7ad4fe1 | |
services: | |
reverseproxy: | |
image: traefik:v2.0 | |
container_name: reverseproxy | |
# Enables the web UI + tells Traefik to listen to docker + provide DEBUG-level logs | |
command: --api.insecure=true --providers.docker --log.Level=DEBUG | |
ports: | |
# The HTTP port | |
- 80:80 | |
# The Web UI (enabled by --api.insecure=true) | |
- "8080:8080" | |
volumes: | |
# So that Traefik can listen to the Docker events | |
- /var/run/docker.sock:/var/run/docker.sock | |
networks: | |
- reverseproxy-network | |
networks: | |
reverseproxy-network: | |
name: reverseproxy-network |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### How proxy a service | |
## 1. label: add filtering rule. See https://doc.traefik.io/traefik/v2.0/routing/providers/docker/ | |
## 2. networks: set "reverseproxy-network" as its external network | |
version: '3' | |
services: | |
app: | |
image: nginx | |
container_name: site1 | |
volumes: | |
- ./index.html:/usr/share/nginx/html/index.html | |
expose: | |
- 80 | |
labels: | |
- traefik.http.routers.site1.rule=Host(`seart-ghs.si.usi.ch`) | |
# below line if this container is listening to specific port | |
- traefik.http.services.site1-service.loadbalancer.server.port=80 | |
- traefik.docker.network=reverseproxy-network | |
networks: | |
- default | |
- reverseproxy | |
networks: | |
default: | |
name: site1_default | |
reverseproxy: | |
external: | |
name: reverseproxy-network | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment