You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All traffic destined to a domain correctly forwarded to a function regardless of the path requested.
Current Behaviour
Depending on installed version of the Traefik, you may observe different behaviors.
If your Traefik version is below v1.7.21, then your function will receive incorrect (duplicated) path, e.g. nodeinfo.example.com/version will be forwarded to gateway/function/nodeinfo/versionversion and your function will get /versionversion as the path. All requests to root path (/) will be forwarded correctly to a function.
If you have Traefik v.1.7.21 or above then you'll get infinite redirect in attempt to request any path (even root)!
The behaviors are different because of this issue that has been addressed in release v1.7.21 of Traefik
Possible Solution
Traefik's rewrite target annotation should be changed from traefik.ingress.kubernetes.io/rewrite-target: /function/FUNC_NAME/$1
to traefik.ingress.kubernetes.io/rewrite-target: /function/FUNC_NAME
where FUNC_NAME is the name of the function.
I've created PR which fixes this issue.
(Nice to have) Document (where?) that Traefik v1.7.21 or above is required
Steps to Reproduce (for bugs)
Disclaimer. I tested all of the following on linux, so not really sure that this would work on Mac or Windows.
Create k8s cluster locally
minikube start
Install traefik as ingress controller. For demonstration purposes, I first install v1.7.20
Let's request the same paths and see what we get (spoiler - infinite redirects). I intentionally limited redirects count to keep the output at acceptable level.
curl -sLv --max-redirs 1 http://podinfo.local.dev
Output:
* Rebuilt URL to: http://podinfo.local.dev/
* Trying 192.168.39.39...
* TCP_NODELAY set
* Connected to podinfo.local.dev (192.168.39.39) port 80 (#0)
> GET / HTTP/1.1
> Host: podinfo.local.dev
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-Length: 0
< Date: Thu, 18 Jun 2020 11:18:59 GMT
< Location: /function/podinfo/
< Vary: Accept-Encoding
<
* Connection #0 to host podinfo.local.dev left intact
* Issue another request to this URL: 'http://podinfo.local.dev/function/podinfo/'
* Found bundle for host podinfo.local.dev: 0x5566c09a19d0 [can pipeline]
* Re-using existing connection! (#0) with host podinfo.local.dev
* Connected to podinfo.local.dev (192.168.39.39) port 80 (#0)
> GET /function/podinfo/ HTTP/1.1
> Host: podinfo.local.dev
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-Length: 0
< Date: Thu, 18 Jun 2020 11:18:59 GMT
< Location: /function/podinfo/function/podinfo/function/podinfo/
< Vary: Accept-Encoding
<
* Connection #0 to host podinfo.local.dev left intact
* Maximum (1) redirects followed
Expected Behaviour
All traffic destined to a domain correctly forwarded to a function regardless of the path requested.
Current Behaviour
Depending on installed version of the Traefik, you may observe different behaviors.
If your Traefik version is below v1.7.21, then your function will receive incorrect (duplicated) path, e.g.
nodeinfo.example.com/version
will be forwarded togateway/function/nodeinfo/versionversion
and your function will get/versionversion
as the path. All requests to root path (/) will be forwarded correctly to a function.If you have Traefik v.1.7.21 or above then you'll get infinite redirect in attempt to request any path (even root)!
The behaviors are different because of this issue that has been addressed in release v1.7.21 of Traefik
Possible Solution
Traefik's rewrite target annotation should be changed from
traefik.ingress.kubernetes.io/rewrite-target: /function/FUNC_NAME/$1
to
traefik.ingress.kubernetes.io/rewrite-target: /function/FUNC_NAME
where
FUNC_NAME
is the name of the function.I've created PR which fixes this issue.
(Nice to have) Document (where?) that Traefik v1.7.21 or above is required
Steps to Reproduce (for bugs)
Disclaimer. I tested all of the following on linux, so not really sure that this would work on Mac or Windows.
or alternatively you can get their services urls to access their UIs
Now the interesting part begins
Output:
Note the two
$1
at the end of the string with the rule. This is why our function gets duplicated path with this Traefik version.Output:
And let's also request the other path
Output:
Function actually gets
/versionversion
as the path.Let's also make sure that this path is handled by requesting it through gateway:
or
Output:
Output:
Output:
Output:
Output:
Output:
Those who made this far: Thanks for reading and don't forget to clean your hosts file at
/etc/hosts
Context
I'm trying to use ingress operator with traefik to forward all traffic from specific domain to function.
Your Environment
Docker version
docker version
(e.g. Docker 17.0.05 ):Docker version 19.03.11, build 42e35e61f3
What version and distriubtion of Kubernetes are you using?
kubectl version
Operating System and version (e.g. Linux, Windows, MacOS):
Ubuntu 18.04.4 LTS
Link to your project or a code example to reproduce issue:
n/a
What network driver are you using and what CIDR? i.e. Weave net / Flannel
n/a
The text was updated successfully, but these errors were encountered: