Add files for youtube demo
This commit is contained in:
commit
42e06bf556
8 changed files with 235 additions and 0 deletions
30
README.md
Normal file
30
README.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# traefik-vs-nginx-docker-youtube
|
||||
|
||||
Examples showing how to use Traefik and Nginx for Reverse Proxy.
|
||||
|
||||
This repository is to complement my YouTube video on this topic, [Traefik vs nginx: Docker Reverse Proxy](https://www.youtube.com/channel/UCm6lURZOeBVCZ5hJpqlUB-g)
|
||||
|
||||
## nginx
|
||||
|
||||
```
|
||||
docker-compose -f docker-compose.nginx.yml up
|
||||
```
|
||||
|
||||
## nginx proxy
|
||||
|
||||
```
|
||||
docker-compose -f docker-compose.nginx-proxy.yml up
|
||||
```
|
||||
|
||||
## traefik
|
||||
|
||||
```
|
||||
docker-compose -f docker-compose.traefik.yml up
|
||||
```
|
||||
|
||||
## traefik with docker network
|
||||
|
||||
```
|
||||
docker-compose -f docker-compose.traefik-network.yml up &
|
||||
docker-compose -f docker-compose.services.yml up
|
||||
```
|
54
default.conf
Normal file
54
default.conf
Normal file
|
@ -0,0 +1,54 @@
|
|||
# HTTP Server
|
||||
server {
|
||||
listen 80 default_server;
|
||||
root /srv/www;
|
||||
|
||||
server_name localhost;
|
||||
|
||||
error_log stderr notice;
|
||||
|
||||
location /whoami {
|
||||
proxy_pass http://whoami;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /ghost {
|
||||
proxy_pass http://ghost:2368;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /ghost2 {
|
||||
proxy_pass http://ghost2:2368;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
access_log off;
|
||||
}
|
||||
}
|
32
docker-compose.nginx-proxy.yml
Normal file
32
docker-compose.nginx-proxy.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
nginx:
|
||||
image: nginxproxy/nginx-proxy
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
whoami:
|
||||
image: 'containous/whoami:latest'
|
||||
environment:
|
||||
VIRTUAL_HOST: localhost
|
||||
VIRTUAL_PATH: /whoami
|
||||
VIRTUAL_PORT: 80
|
||||
|
||||
ghost:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost
|
||||
VIRTUAL_HOST: localhost
|
||||
VIRTUAL_PATH: /ghost
|
||||
VIRTUAL_PORT: 2368
|
||||
|
||||
ghost2:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost2
|
||||
VIRTUAL_HOST: localhost
|
||||
VIRTUAL_PATH: /ghost2
|
||||
VIRTUAL_PORT: 2368
|
||||
|
22
docker-compose.nginx.yml
Normal file
22
docker-compose.nginx.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- "./default.conf:/etc/nginx/conf.d/default.conf"
|
||||
|
||||
whoami:
|
||||
image: 'containous/whoami:latest'
|
||||
|
||||
ghost:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost
|
||||
|
||||
ghost2:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost2
|
||||
|
25
docker-compose.services.yml
Normal file
25
docker-compose.services.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
whoami2:
|
||||
image: 'traefik/whoami'
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.whoami2.rule=PathPrefix(`/whoami2{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.whoami2.loadbalancer.server.port=80'
|
||||
networks:
|
||||
- home
|
||||
|
||||
ghost2:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost2
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.ghost2.rule=PathPrefix(`/ghost2{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.ghost2.loadbalancer.server.port=2368'
|
||||
networks:
|
||||
- home
|
||||
|
||||
networks:
|
||||
home:
|
||||
external: true
|
36
docker-compose.traefik-network.yml
Normal file
36
docker-compose.traefik-network.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
traefik:
|
||||
image: 'traefik:latest'
|
||||
ports:
|
||||
- '80:80'
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
- './traefik.yml:/etc/traefik/traefik.yml'
|
||||
- '/var/run/docker.sock:/var/run/docker.sock:ro'
|
||||
networks:
|
||||
- home
|
||||
|
||||
whoami:
|
||||
image: 'traefik/whoami'
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.whoami.rule=PathPrefix(`/whoami{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.whoami.loadbalancer.server.port=80'
|
||||
networks:
|
||||
- home
|
||||
|
||||
ghost:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.ghost.rule=PathPrefix(`/ghost{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.ghost.loadbalancer.server.port=2368'
|
||||
networks:
|
||||
- home
|
||||
|
||||
networks:
|
||||
home:
|
||||
external: true
|
26
docker-compose.traefik.yml
Normal file
26
docker-compose.traefik.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
traefik:
|
||||
image: 'traefik:latest'
|
||||
ports:
|
||||
- '80:80'
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
- './traefik.yml:/etc/traefik/traefik.yml'
|
||||
- '/var/run/docker.sock:/var/run/docker.sock:ro'
|
||||
|
||||
whoami:
|
||||
image: 'traefik/whoami'
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.whoami.rule=PathPrefix(`/whoami{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.whoami.loadbalancer.server.port=80'
|
||||
|
||||
ghost:
|
||||
image: 'ghost:latest'
|
||||
environment:
|
||||
url: http://localhost/ghost
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.ghost.rule=PathPrefix(`/ghost{regex:$$|/.*}`)'
|
||||
- 'traefik.http.services.ghost.loadbalancer.server.port=2368'
|
10
traefik.yml
Normal file
10
traefik.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
## traefik.yml
|
||||
|
||||
# Docker configuration backend
|
||||
providers:
|
||||
docker:
|
||||
defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
|
||||
|
||||
# API and dashboard configuration
|
||||
api:
|
||||
insecure: true
|
Loading…
Reference in a new issue