traefik开启https,请求进入后跳转:80–>443,通过traefik后,是以http方式请求后端服务
运行
docker-compose文件如下:
version: "2"
services:
proxy:
image: traefik
command: --web --docker --logLevel=DEBUG
networks:
- webgateway
ports:
- "80:80"
- "8080:8080"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/etc/traefik/traefik.toml
- ./ssl/nginx.crt:/ssl/nginx.crt
- ./ssl/nginx.key:/ssl/nginx.key
labels:
- "traefik.enable=false"
nginx:
image: nginx:1.14.2-alpine
networks:
- webgateway
volumes:
- ./http.conf:/etc/nginx/conf.d/default.conf
- ./index.html:/code/backend/web/index.html
- ./index.php:/code/backend/web/index.php
labels:
- "traefik.backend=php"
- "traefik.frontend.rule=Host:test.example.com"