Proxying a subfolder to a subdomain

Salut !

Traefik noob here :see_no_evil:

I am trying to setup the following thing:

  • I have a 3rd party integration running on subdomain.example.com, say something like a website builder or landing page builder. Colleagues can create as many page as they want subdomain.example.com/page1, subdomain.example.com/page2, etc...
  • I want these pages to be available at example.com/magicstring/page1, example.com/magicstring/page2, etc...

About my setup:

  • I already have my main website running on example.com, hence the need for magicstring
  • We use traefik, kubernetes, helm and tiller. I'm not a devops person and my understanding is limited.
    I sat down with one of our devops person and we tried setting this up in main toml config file by doing something like this:
[frontends]
  [frontends.pagegenerator]
  backend = "thirdparty"
  [frontends.frontend1.routes.pagegenerator]
  rule = "PathPrefixStrip:/magicstring"
[backends]
  [backends.thirdparty]
    [backends.thirdparty.servers.server1]
    url = "https://thirdparty.example.com/"

However that did not work out :frowning:

I think a summary of my question would be: can I use ingress or service annotations to make traefik proxy a request to a specific backend to another url ?

santé :wine_glass:

Hello,

you can try something like that:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
  namespace: testing
  annotations:
    ingress.kubernetes.io/rule-type: "PathPrefixStrip"

spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /magicstring
        backend:
          serviceName: service1
          servicePort: 80

https://docs.traefik.io/v1.7/configuration/backends/kubernetes/#general-annotations

[frontends]

  [frontends.pagegenerator]
    backend = "thirdparty"
    [frontends.pagegenerator.routes.route0]
    rule = "Host:example.com; PathPrefixStrip:/magicstring"

[backends]

  [backends.thirdparty]
    [backends.thirdparty.servers]
      [backends.thirdparty.servers.server0]
        url = "https://subdomain.example.com"