【发布时间】:2020-05-06 21:31:53
【问题描述】:
我不知道如何在本地主机上通过 http 和 https 访问一个简单的服务。这是我目前的设置,我使用的是 traefik V2.xxx。
我希望能够同时使用 https/http 协议访问该站点(仅出于开发机器上的原因)。 https 工作得很好,但 http 不行。我需要添加/删除/更改哪些标签?
http://whoami.localhost:8000/
https://whoami.localhost:8443/
docker-compose.yml
version: "3.7"
services:
whoami:
image: containous/whoami
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=Host(`whoami.localhost`)
- traefik.http.routers.whoami.entrypoints=web,web-secure
- traefik.http.routers.whoami.tls=true
- traefik.protocol=http,https
reverse-proxy:
depends_on:
- whoami
image: traefik:v2.1.1
ports:
- 8000:80
- 8443:443
- 8001:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik:/etc/traefik:ro
traefik/traefik.toml
[log]
level = "DEBUG"
[accessLog]
filePath = "/logs/access.log"
bufferingSize = 20
[docker]
exposedbydefault = false
[api]
dashboard = true
insecure = true
[providers]
[providers.file]
filename = "/etc/traefik/traefik.toml"
watch = true
[providers.docker]
exposedbydefault = false
[[tls.certificates]]
certFile = "/etc/traefik/certs/localhost-cert.pem"
keyFile = "/etc/traefik/certs/localhost-key.pem"
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web-secure]
address = ":443"
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 whoami.localhost
【问题讨论】:
标签: docker docker-compose traefik