HTTPS 重定向 traefik v2
HTTPS redirect traefik v2
我正在尝试在我们拥有的开发服务器上设置 traefik v2。
设置:
Docker 为数十个 nginx 容器提供服务,充当不同项目的前端。每个 nginx 容器都有一个链接到它的唯一域。 Nginx 运行 在端口 80 上。每个项目都有一个单独的 docker-compose(traefik 也有一个单独的 docker-compose)。
我想要完成的事情:
将所有容器代理到 traefik 并随时添加新容器(新服务始终 stopped/started)。让 traefik 自动重定向到 HTTPS 并根据主机名联系适当的 nginx 容器,以便为网站提供服务。
问题:这甚至可以做到吗?在过去一天左右的时间里,我一直在努力解决这个问题,但我无法让一切正常工作。要么重定向不起作用,要么重定向 returns 404.
设法找到涵盖此内容的指南:
https://chriswiegman.com/2019/10/serving-your-docker-apps-with-https-and-traefik-2/
为了扩展指南所指出的内容,魔术酱在标签中。可以分解为:
# Setup HTTP
# tells traefik that cany HTTP connection needs to be re-directed to HTTPS
- "traefik.http.middlewares.mysite-https.redirectscheme.scheme=https"
# 'web' (or any name) can be defined my traefik entrypoints. Web is port 80.
- "traefik.http.routers.mysite-http.entrypoints=web"
# tells to route incoming connections to 'mysitesdomain.com' to this service
- "traefik.http.routers.mysite-http.rule=Host(`mysitesdomain.com`)"
# Maps the above 'middleware' called 'mysite-https'
- "traefik.http.routers.mysite-http.middlewares=mysite-https@docker"
# Setup HTTPS
- "traefik.http.routers.mysite.entrypoints=web-secure"
- "traefik.http.routers.mysite.rule=Host(`mysitesdomain.com`)"
- "traefik.http.routers.mysite.tls=true"
- "traefik.http.routers.mysite.tls.certresolver=default"
似乎缺少负载均衡器定义。
- "traefik.http.services.replica_service.loadbalancer.server.port=80" # "80" is the container's incoming port.
我正在尝试在我们拥有的开发服务器上设置 traefik v2。
设置:
Docker 为数十个 nginx 容器提供服务,充当不同项目的前端。每个 nginx 容器都有一个链接到它的唯一域。 Nginx 运行 在端口 80 上。每个项目都有一个单独的 docker-compose(traefik 也有一个单独的 docker-compose)。
我想要完成的事情:
将所有容器代理到 traefik 并随时添加新容器(新服务始终 stopped/started)。让 traefik 自动重定向到 HTTPS 并根据主机名联系适当的 nginx 容器,以便为网站提供服务。
问题:这甚至可以做到吗?在过去一天左右的时间里,我一直在努力解决这个问题,但我无法让一切正常工作。要么重定向不起作用,要么重定向 returns 404.
设法找到涵盖此内容的指南:
https://chriswiegman.com/2019/10/serving-your-docker-apps-with-https-and-traefik-2/
为了扩展指南所指出的内容,魔术酱在标签中。可以分解为:
# Setup HTTP
# tells traefik that cany HTTP connection needs to be re-directed to HTTPS
- "traefik.http.middlewares.mysite-https.redirectscheme.scheme=https"
# 'web' (or any name) can be defined my traefik entrypoints. Web is port 80.
- "traefik.http.routers.mysite-http.entrypoints=web"
# tells to route incoming connections to 'mysitesdomain.com' to this service
- "traefik.http.routers.mysite-http.rule=Host(`mysitesdomain.com`)"
# Maps the above 'middleware' called 'mysite-https'
- "traefik.http.routers.mysite-http.middlewares=mysite-https@docker"
# Setup HTTPS
- "traefik.http.routers.mysite.entrypoints=web-secure"
- "traefik.http.routers.mysite.rule=Host(`mysitesdomain.com`)"
- "traefik.http.routers.mysite.tls=true"
- "traefik.http.routers.mysite.tls.certresolver=default"
似乎缺少负载均衡器定义。
- "traefik.http.services.replica_service.loadbalancer.server.port=80" # "80" is the container's incoming port.