我用fargate为Traefik得到404。使用简单的http配置尝试Traefik,我的Traefik仪表板工作正常。我的后端是简单的java spring boot项目,它也运行良好。每当我尝试通过Traefik调用我的后端时,都会出现404
TRAEFIK ecs任务定义
[
{
"name": "gateway",
"image": "traefik:latest",
"essential": true,
"command": [
"--api"
],
"essential": true,
"portMappings": [
{
"hostPort": 8080,
"containerPort": 8080
},
{
"hostPort": 443,
"containerPort": 443
},
{
"hostPort": 4443,
"containerPort": 4443
}
],
"dockerLabels": {
"traefik.enable": "true",
"traefik.backend": "traefik"
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/traefik",
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "ecs"
}
},
"environment": [
{
"name": "AWS_REGION",
"value": "eu-central-1"
}
]
}
]
TOML文件
defaultEntryPoints = ["http", "https"]
logLevel = "DEBUG" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
[accessLog]
format = "json"
[accessLog.fields.headers]
defaultMode = "drop"
[accessLog.fields.headers.names]
"Accept" = "keep"
"Accept-Encoding" = "keep"
"Accept-Language" = "keep"
"Referer" = "keep"
"User-Agent" = "keep"
"Cache-Control" = "keep"
"Content-Encoding" = "keep"
"Content-Type" = "keep"
"X-Trace-Id" = "keep"
[traefikLog]
format = "json"
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.https]
address = ":443"
[ecs]
clusters = ["traefik"]
watch = true
autoDiscoverClusters = true
refreshSeconds = 15
exposedByDefault = true
region = "eu-central-1"
我的中间件任务定义。
[
{
"name": "middleware",
"image": "sample:latest",
"essential": true,
"portMappings": [
{
"hostPort": 8181,
"containerPort": 8181
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-region": "eu-central-1",
"awslogs-group": "/ecs/middleware",
"awslogs-stream-prefix": "middleware"
}
},
"dockerLabels": {
"traefik.frontend.rule": "PathPrefix:/sample",
"traefik.frontend.entryPoints": "http"
}
}
]