Http redirect in K8s

I use Traefik 1.7 with Letsencrypt in K8s. It works when I do requests with https-prefix. However http is not redirected.
I configured redirection in toml-file and I do three annotations in my ingress-yml

Annotations: traefik https "true"

When I call with http-prefix answer is "found".

What is missing?

Here are two Logentries from traefik(first https, second http): - - [17/Mar/2021:09:04:22 +0000] "GET / HTTP/2.0" 200 23 "-" "curl/7.58.0" 4 "" "" 3ms - - [17/Mar/2021:09:04:32 +0000] "GET / HTTP/1.1" 302 5 "-" "curl/7.58.0" 5 "entrypoint redirect for http" "/" 0ms

One remark: My K8s runs in Oracle-Cloud.

My maybe very simplified picture was: I can configure http-redirect global in toml-file. I did

      address = ":80"
      entryPoint = "https"
      address = ":443"

Later I tried

      address = ":80"
      regex = "^http://(.*)"
      replacement = "https://$1"
      address = ":443"

But redirect doesn't work this way.

And I thought that I can configure http-redirect per ingress with a annotation in Ingress-yml.
Worked neither.

Any advise?

For redirection at the ingress level try this:

annotations: "true" "true"

I tried it, but no success.

k describe ingress kubia-ingress
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use Ingress
Name:             kubia-ingress
Namespace:        default
Default backend:  kubia:80 (,,
  Host                          Path  Backends
  ----                          ----  --------  
                                /      kubia:80 (,,
                                /bee   bee:80 (,,
Annotations:           true
Events:                         <none>

https works, http-redirect dows not. Here are the two log entries, first is http-curl-call, second is https-curl-call. - - [23/Mar/2021:09:30:25 +0000] "GET / HTTP/1.1" 302 5 "-" "curl/7.61.1" 1 "entrypoint redirect for http" "/" 0ms - - [23/Mar/2021:09:30:29 +0000] "GET / HTTP/2.0" 200 23 "-" "curl/7.61.1" 2 "" "" 1ms

Please look also here. Because I got no response here in the forum I duplicated my question(sorry):

can you post your curl commands and output?

try using curl -L -v

Just to be sure: I want only TLS-communication when a client from outside requests via http. In this case it should be redirect to https. The communication inside K8s should be http.
I thought this is simply done globally by confgiration in the toml-file of traefik with this

      address = ":80"
         entryPoint = "https"
*   Trying
* Connected to ( port 80 (#0)
> GET / HTTP/1.1
> Host:
> User-Agent: curl/7.61.1
> Accept: */*
< HTTP/1.1 302 Found
< Location:
< Date: Tue, 23 Mar 2021 09:57:42 GMT
< Content-Length: 5
< Content-Type: text/plain; charset=utf-8
* Ignoring the response-body
* Connection #0 to host left intact
* Issue another request to this URL: ''
*   Trying
* Connected to ( port 443 (#1)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self signed certificate
* Closing connection 1
curl: (60) SSL certificate problem: self signed certificate
More details here:

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

I just had to add --insecure to curl!

[opc@bastionhost ~]$ curl -L  --insecure
You've hit kubia-85ntl
[opc@bastionhost ~]$ curl --insecure
Found[opc@bastionhost ~]$

I have to apply both options... -L and --insecure

I ommited the -L option the first time...

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.