Redirecting to Traefik from one domain to another

According to the documentation, you should be able to use Traefik redirect 302 using:

  • traefik.ingress.kubernetes.io/redirect-regex
  • traefik.ingress.kubernetes.io/redirect-replacement

My goal is simply to remove www.from the address.

This is what I tried, but I did not find the 404 service.

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: www-redirect
  namespace: public
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/redirect-regex: ^https?://www.example.com/(.*)
    traefik.ingress.kubernetes.io/redirect-replacement: https://example.com/$1
spec:
  rules:
  - host: www.example.com

Unfortunately, the documentation does not indicate how to use them. At the time of writing, the only hit by Google is the documentation (see above).

My current job (assuming this helps explain the question) is traffic www.on nginx, which returns 302.

server {
    listen       80;
    server_name  www.example.com;
    return 302 https://example.com$request_uri;
}

That seems redundant.

+4
source share

Source: https://habr.com/ru/post/1693203/


All Articles