简体   繁体   中英

Traefik kubernetes crd - proxy external host

Can traefik act as a reverse proxy for some external endpoint? Like nginx's proxy path for a specific location. For example, I'd like to perform transparent reverse-proxying to https://app01.host.com which is in another datacenter

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: backend01-ingressroute-app
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`backend01.host.local`) && PathPrefix(`/app`)
    kind: Rule
    services:
....

backend01.host.local/app -> https://app01.host.com ? But what I need to specify as "services" here to achieve that?

I found that external name services are per default disabled when using traefik with helm. Note that this has to be set for kube.netesCRD and for kube.netesIngress seperately. This is not explained well in the documentation: https://doc.traefik.io/traefik/routing/providers/kube.netes-crd/#kind-ingressroute

traefik helm values file:

...
#
# Configure providers
#
providers:
  kubernetesCRD:
    enabled: true
    allowCrossNamespace: false
    allowExternalNameServices: false # <- This needs to be true
    # ingressClass: traefik-internal
    # labelSelector: environment=production,method=traefik
    namespaces:
      []
      # - "default"

  kubernetesIngress:
    enabled: true
    allowExternalNameServices: false # <- This needs to be true
    # labelSelector: environment=production,method=traefik
    namespaces:
...

Yes. The traefik documentation on ExternalName services pretty much covers the use case you're looking for

https://docs.traefik.io/routing/providers/kube.netes-crd/

Couldn't get a direct link, so please do a "find in page" for ExternalName

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM