spring-boot - Traefik 2.2 网关超时问题
问题描述
我一直在尝试使用基本官方指南设置 traefik v2.2。我有一个 Spring Boot 服务,我已经将它容器化并且工作正常。
这是我的 spring boot 服务的 docker compose:
version: "3"
services:
spring-boot-traefik-app:
image: spring-boot-traefik-example:latest
labels:
- "traefik.http.routers.spring-boot-traefik-app.rule=Host(`springboot.traefik.app`)"
这是我的 Traefik docker compose :
version: "3"
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.2
# Enables the web UI and tells Traefik to listen to docker
command:
- "--api.insecure=true"
- "--providers.docker=true"
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
现在,我正在尝试通过以下方式执行 curl 请求:
curl -H Host:springboot.traefik.app http://127.0.0.1
因为我只是在上下文路径“/”上返回服务信息,所以它应该返回了一些东西。服务独立工作正常。但是当我尝试在代理后面运行时,它会给我网关超时错误。我不确定 traefik 是否正常工作。我错过了什么吗?官方指南使用 whoami 图像,这是我试图用 Spring boot 创建的。此外,traefik 仪表板可以正确显示详细信息。
解决方案
也许您应该为您的 traefik 配置定义一个入口点。您可能没有 traefik.toml 文件(我更喜欢个人使用)。无论如何,您应该--entryPoints.web.address=:80
为您的 traefik 容器添加命令,并将标签添加到traefik.http.routers.spring-boot-traefik-app.entrypoints=web
您的 springboot 容器中。我希望它有效!
推荐阅读
- typescript - 可观察链、flatMap 和类型转换
- go - 无法从 Go 安装 revel 框架
- css - 如何使用 Microsoft Edge 和 Internet Explorer 11 开发人员工具检查伪元素
- python - 用 n-1 替换缺失值
- linux - 在 linux 命令行中使用 find 和 grep 搜索具有特定用户和文本内容的文件?
- php - 在 Woocommerce 中用节省的金额和百分比替换特价产品价格
- postgresql - 执行查询时使用“ALL”运算符时出错
- rsa-key-fingerprint - 修改 Python 3 代码以处理 RSA 密钥指纹
- c# - 反序列化具有不同属性的 JSON
- excel - 如何在行中查找重复值?