I am getting 404 for Traefik with fargate. Trying Traefik with simple http configuration , my Traefik dashboard is working fine. My backend is simple java spring boot project is also running fine. Whenever I am trying to call my backend with Traefik , there is a 404
TRAEFIK ecs Task definition
[
{
"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"
}
]
}
]
The TOML file
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"
My middleware task definition.
[
{
"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"
}
}
]
Related
I have implemented Ocelot API Gateway in my Net Core 7 application. One of the JSON files containing routes is set up as follows:
{
"Routes": [
{
"DownstreamPathTemplate": "/storedfiletype",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "<<<HOST DELETED FOR SECURITY>>>",
"Port": 443
}
],
"UpstreamPathTemplate": "/fileserver/storedfiletype",
"UpstreamHttpMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/storedfiletype/fileextension",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "<<<HOST DELETED FOR SECURITY>>>",
"Port": 443
}
],
"UpstreamPathTemplate": "/fileserver/storedfiletype/fileextension",
"UpstreamHttpMethod": [ "Post" ]
}
]
}
Now when I try and post to the first route (/storedfiletype in this case), I get a 404 error but the second route works. When I swap them over (making /storedfiletype/fileextension the first route), /storedfiletype works and /storedfiletype/fileextension gives me the 404 error.
Any ideas?
I'm trying to get Identity server 4 to work in an ASP Net Core 3 application with an Angular 8 SPA using "oidc-client": "1.10.1".
If I add the following to my appsettings.json
"IdentityServer": {
"Key": {
"Type": "File",
"FilePath": "acertificate.pfx",
"Password": "notmyrealpassword..orisit?"
},
"Clients": {
"dev-client": {
"Profile": "IdentityServerSPA",
}
}
}
Using this client:
{
authority: 'https://localhost:5001/',
client_id: 'dev-client',
redirect_uri: 'http://localhost:4200/auth-callback',
post_logout_redirect_uri: 'http://localhost:4200/',
response_type: 'id_token token',
scope: 'openid profile API',
filterProtocolClaims: true,
loadUserInfo: true
}
I get: Invalid redirect_uri: http://localhost:4200/auth-callback
adding.
"dev-client": {
"Profile": "IdentityServerSPA",
"RedirectUris": [ "http://localhost:4200/auth-callback" ]
}
does nothing. If I add the Client config copied (almost) from the documentation
"Clients": [
{
"Enabled": true,
"ClientId": "dev-client",
"ClientName": "Local Development",
"AllowedGrantTypes": [ "implicit" ],
"AllowedScopes": [ "openid", "profile", "API" ],
"RedirectUris": [ "http://localhost:4200/auth-callback" ],
"RequireConsent": false,
"RequireClientSecret": false
}
]
I get: System.InvalidOperationException: 'Type '' is not supported.' at startup
If I try to configure the client in code, and only keep the "Key" section in appsettings
services
.AddIdentityServer(options =>
{
options.Cors.CorsPolicyName = _CorsPolicyName;
})
.AddInMemoryClients(new IdentityServer4.Models.Client[] {
new IdentityServer4.Models.Client
{
ClientId = "dev-client",
ClientName = "JavaScript Client",
ClientUri = "http://localhost:4200",
AllowedGrantTypes = { IdentityModel.OidcConstants.GrantTypes.Implicit },
AllowAccessTokensViaBrowser = true,
RedirectUris = { "http://localhost:4200/auth-callback" },
PostLogoutRedirectUris = { "http://localhost:4200" },
AllowedCorsOrigins = { "http://localhost:4200" },
AllowedScopes =
{
IdentityServer4.IdentityServerConstants.StandardScopes.OpenId,
IdentityServer4.IdentityServerConstants.StandardScopes.Profile,
IdentityServer4.IdentityServerConstants.StandardScopes.Email,
"API"
}
}
})
I get: Unknown client or not enabled: dev-client.
Someone help me keep my sanity and point out my, most likely obvious, error.
ASP.NET Identity overrides the documented method for IdentityServer Clients configuration, expecting a dictionary of well-known values. You can bypass this by creating a section that is not named Clients and reading from that section explicitly. Additionally, AddApiAuthorization exposes the Clients collection on the ApiAuthorizationOptions, which can be used to add other clients:
.AddApiAuthorization<...>(options =>
{
options.Clients.AddRange(Configuration.GetSection("IdentityServer:OtherClients").Get<Client[]>());
});
I would like to expose internal metrics of traefik.
After reading the documentation I created the following configuration file:
logLevel = "INFO"
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.dashboard]
address = ":16081"
# API definition
[api]
entryPoint = "dashboard"
dashboard = true
debug = false
[api.statistics]
recentErrors = 10
# Metrics definition
[metrics]
# DataDog metrics exporter type
[metrics.datadog]
address = "172.17.0.1:8125"
pushInterval = "10s"
################################################################
# Mesos/Marathon Provider
################################################################
# Enable Marathon Provider.
[marathon]
endpoint = "http://mesos.lan:8080/"
watch = true
domain = "service.lan"
exposedByDefault = false
When I query the dashboard entrypoint I got a 404 error on /metrics:
curl -s http://localhost:16081/health | jq
{
"pid": 1,
"uptime": "3h31m3.5252748s",
"uptime_sec": 12663.5252748,
"time": "2018-09-04 16:53:17.7128687 +0000 UTC m=+12663.602939001",
"unixtime": 1536079997,
"status_code_count": {},
"total_status_code_count": {
"404": 5
},
"count": 0,
"total_count": 5,
"total_response_time": "390.7µs",
"total_response_time_sec": 0.0003907,
"average_response_time": "78.14µs",
"average_response_time_sec": 7.814e-05,
"recent_errors": [
{
"status_code": 404,
"status": "Not Found",
"method": "GET",
"host": "localhost:16081",
"path": "/metrics",
"time": "2018-09-04T16:53:12.0232879Z"
},
{
"status_code": 404,
"status": "Not Found",
"method": "GET",
"host": "localhost:16081",
"path": "/metrics",
"time": "2018-09-04T13:18:52.7206202Z"
},
{
"status_code": 404,
"status": "Not Found",
"method": "GET",
"host": "localhost:16081",
"path": "/metrics",
"time": "2018-09-04T13:18:51.853093Z"
},
{
"status_code": 404,
"status": "Not Found",
"method": "GET",
"host": "localhost:16081",
"path": "/metrics",
"time": "2018-09-04T13:18:50.9894516Z"
},
{
"status_code": 404,
"status": "Not Found",
"method": "GET",
"host": "localhost:16081",
"path": "/metrics",
"time": "2018-09-04T13:18:49.8598176Z"
}
]
}
curl -s http://localhost:16081/metrics
404 page not found
Did I miss something ?
My main objective is to be able to get metrics per frontend/backend.
I would like to be able to know the number of requests and returned status code per frontend.
Thanks,
Renaud
This is solved, long story short, /metrics is only exposed when promotheus provider is enable. When Datadog provider is enable all the metrics are sent to datadog.
Details can be found here: github.com/containous/traefik/issues/3877
My frontend don't go on the backend 🤔
Example:
$ curl rancher.foo.bar
404 page not found
$ curl http://172.17.0.3:8080
{"id":"v1", ...}
# traefik
$ curl http://foo.bar:8080/api/providers
{
"docker": {
"backends": {
"backend-rancher": {
"servers": {
"server-rancher": {
"url": "http://172.17.0.3:8080",
"weight": 0
}
},
"loadBalancer": {
"method": "wrr"
}
}
},
"frontends": {
"frontend-rancher-foo-bar-0": {
"entryPoints": [
"http"
],
"backend": "backend-rancher",
"routes": {
"route-frontend-rancher-foo-bar-0": {
"rule": "rancher.foo.bar"
}
},
"passHostHeader": true,
"priority": 0,
"basicAuth": []
}
}
}
}
What's wrong ?
Why I get a 404 and not the a 200 ?
Thanks
You must change the rule on your frontend to Host:rancher.foo.bar
When trying to use IPFS from my localhost I am having trouble accessing the IPFS service. I tried setting my config to accept the localhost and all server stuff, but nothing seems to work.
The error:
Failed to load http://127.0.0.1:5001/api/v0/files/stat?arg=0x6db883c6f3b2824d26f3b2e9c30256b490d125b10a3942f49a1ac715dd2def89&stream-channels=true: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
IPFS Config:
{
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Origin": [
"*"
]
}
},
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Announce": [],
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
},
"Bootstrap": [
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
"/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
"/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
"/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"
],
"Datastore": {
"BloomFilterSize": 0,
"GCPeriod": "1h",
"HashOnRead": false,
"Spec": {
"mounts": [
{
"child": {
"path": "blocks",
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
"sync": true,
"type": "flatfs"
},
"mountpoint": "/blocks",
"prefix": "flatfs.datastore",
"type": "measure"
},
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
}
],
"type": "mount"
},
"StorageGCWatermark": 90,
"StorageMax": "10GB"
},
"Discovery": {
"MDNS": {
"Enabled": true,
"Interval": 10
}
},
"Experimental": {
"FilestoreEnabled": false,
"Libp2pStreamMounting": false,
"ShardingEnabled": false
},
"Gateway": {
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Range"
],
"Access-Control-Allow-Methods": [
"GET"
],
"Access-Control-Allow-Origin": [
"localhost:63342"
]
},
"PathPrefixes": [],
"RootRedirect": "",
"Writable": false
},
"Identity": {
"PeerID": "QmRgQdig4Z4QNEqs5kp45bmq6gTtWi2qpN2WFBX7hFsenm"
},
"Ipns": {
"RecordLifetime": "",
"RepublishPeriod": "",
"ResolveCacheSize": 128
},
"Mounts": {
"FuseAllowOther": false,
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"Reprovider": {
"Interval": "12h",
"Strategy": "all"
},
"Swarm": {
"AddrFilters": null,
"ConnMgr": {
"GracePeriod": "20s",
"HighWater": 900,
"LowWater": 600,
"Type": "basic"
},
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"DisableRelay": false,
"EnableRelayHop": false
}
}
Ben, try replacing 127.0.0.1 with localhost. go-ipfs whitelists localhost only. Also check https://github.com/ipfs/js-ipfs-api/#cors
my answer might come very late, however I am trying to solve some CORS issues with IPFS on my end; therefore I might have a solution for you:
by running:
# please update origin according to your setup...
origin=http://localhost:63342
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["'"$origin"'", "http://127.0.0.1:8080","http://localhost:3000", "http://127.0.0.1:48084", "https://gateway.ipfs.io", "https://webui.ipfs.io"]'
ipfs config API.HTTPHeaders.Access-Control-Allow-Origin
and restarting your ipfs daemon it might fix it
if the "fetch" button in the following linked page works : you are all set ! https://gateway.ipfs.io/ipfs/QmXkhGQNruk3XcGsidCzQbcNQ5a8oHWneHZXkPvWB26RbP/
This Command Works for me
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin
'["'"$origin"'", "http://127.0.0.1:8080","http://localhost:3000"]'
you can allow the request from multiple origins