Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
7513d39eb6 | |||
0436310086 | |||
82659b67e9 | |||
c7d69b2af3 | |||
9ec91834aa | |||
d345d47c9f |
78
docker-traefik-nginx/Vagrantfile
vendored
78
docker-traefik-nginx/Vagrantfile
vendored
@ -13,7 +13,7 @@ Vagrant.configure("2") do |config|
|
|||||||
# Every Vagrant development environment requires a box. You can search for
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
# boxes at https://vagrantcloud.com/search.
|
# boxes at https://vagrantcloud.com/search.
|
||||||
config.vm.box = "debian/bullseye64"
|
config.vm.box = "debian/bullseye64"
|
||||||
config.vm.hostname = "glpi"
|
config.vm.hostname = "traefikb"
|
||||||
|
|
||||||
# Disable automatic box update checking. If you disable this, then
|
# Disable automatic box update checking. If you disable this, then
|
||||||
# boxes will only be checked for updates when the user runs
|
# boxes will only be checked for updates when the user runs
|
||||||
@ -66,52 +66,52 @@ Vagrant.configure("2") do |config|
|
|||||||
# documentation for more information about their specific syntax and use.
|
# documentation for more information about their specific syntax and use.
|
||||||
config.vm.provision "shell", inline: <<-SHELL
|
config.vm.provision "shell", inline: <<-SHELL
|
||||||
apt-get update
|
apt-get update
|
||||||
apt install -y wget curl git vim
|
apt-get install -y wget curl git vim libnss3-tools
|
||||||
if ! which docker ; then
|
if ! which docker ; then
|
||||||
curl -s -o getdocker.sh https://get.docker.com
|
curl -s -o getdocker.sh https://get.docker.com
|
||||||
bash getdocker.sh
|
bash getdocker.sh
|
||||||
gpasswd -a vagrant docker
|
gpasswd -a vagrant docker
|
||||||
fi
|
fi
|
||||||
mkdir -p docker/traefik && cd docker/traefik
|
mkdir -p docker/traefik && cd docker/traefik
|
||||||
cat > docker-compose.yml <<-EOT
|
mkdir nginx
|
||||||
version: "3.2"
|
echo "my.nginx" > nginx/index.html
|
||||||
traefik:
|
mkdir nginx2
|
||||||
image: traefik:latest
|
echo "my.nginx2" > nginx2/index.html
|
||||||
command:
|
#cat > docker-compose.yml <<-EOT
|
||||||
- --entrypoints.web.address=:80
|
cat > docker-compose.yml <<'EOT'
|
||||||
- --entrypoints.websecure.address=:443
|
version: '3'
|
||||||
- --providers.docker=true
|
|
||||||
- --providers.file.directory=/etc/traefik/dynamic_conf
|
|
||||||
- --providers.file.watch=true
|
|
||||||
ports:
|
|
||||||
- 80:80
|
|
||||||
- 443:443
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
- ./certs/:/certs/:ro
|
|
||||||
- ./traefik.yml:/etc/traefik/dynamic_conf/conf.yml:ro
|
|
||||||
|
|
||||||
web:
|
services:
|
||||||
image: nginx:1.17.8-alpine
|
reverse-proxy:
|
||||||
labels:
|
# The official v2 Traefik docker image
|
||||||
# http with redirection
|
image: traefik:latest
|
||||||
- traefik.http.middlewares.redirect-middleware.redirectscheme.scheme=https
|
# Enables the web UI and tells Traefik to listen to docker
|
||||||
- traefik.http.routers.web-router.entrypoints=web
|
command: --api.insecure=true --providers.docker
|
||||||
- traefik.http.routers.web-router.rule=Host(`your-domain.net`)
|
ports:
|
||||||
- traefik.http.routers.web-router.middlewares=redirect-middleware
|
# The HTTP port
|
||||||
# https
|
- "80:80"
|
||||||
- traefik.http.routers.websecure-router.entrypoints=websecure
|
# The Web UI (enabled by --api.insecure=true)
|
||||||
- traefik.http.routers.websecure-router.tls=true
|
- "8080:8080"
|
||||||
- traefik.http.routers.websecure-router.rule=Host(`your-domain.net`)
|
volumes:
|
||||||
EOT
|
# So that Traefik can listen to the Docker events
|
||||||
cat > mariadb.env <<-EOT
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
tls:
|
nginx:
|
||||||
certificates:
|
# A container that exposes an API to show its IP address
|
||||||
- certFile: /certs/awx.afone.priv.crt
|
image: nginx:1.23-alpine
|
||||||
keyFile: /certs/awx.afone.priv.key
|
volumes:
|
||||||
EOT
|
- ./nginx:/usr/share/nginx/html:ro
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.nginx.rule=Host(`my.nginx`)"
|
||||||
|
nginx2:
|
||||||
|
# A container that exposes an API to show its IP address
|
||||||
|
image: nginx:1.23-alpine
|
||||||
|
volumes:
|
||||||
|
- ./nginx2:/usr/share/nginx/html:ro
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.nginx2.rule=Host(`my.nginx2`)"
|
||||||
|
'EOT'
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
ip -br a
|
ip -br a
|
||||||
SHELL
|
SHELL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user