Two routes for http and https in one ingressroute

Is it possible to have two routes like below in one ingressroute:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend
  namespace: example
spec:
  entryPoints:
    - web
    - websecure
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    - name: example-backend-service
      port: 80
  tls:
    secretName: tls-secret # I'm using my own certificate, not Let's Encrypt
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    - name: example-backend-service
      port: 80

As the TLS applies on a router, you cannot have only one IngressRoute to handle the 2 cases.

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend
  namespace: example
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    - name: example-backend-service
      port: 80
  tls:
    secretName: tls-secret

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend-redirect
  namespace: example
spec:
  entryPoints:
    - web
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    # in this IngressRoute the service will be never called
    # because of the redirect middleware.
    - name: example-backend-service
      port: 80
    middlewares:
    - name: https_redirect

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https_redirect
spec:
  redirectScheme:
    scheme: https
    permanent: true

Can I use File provider and use dynamic configuration.

The dynamic configuration is provided by:

  • the file provider
  • CRD files (k8s)
  • ingress (k8s)
  • labels (Docker, Rancher, ...)
  • tags (Consul Catalog)

doc:

So I don't understand your question.