Is it possible for traefik to append index.html to empty ('/') paths?

950 views Asked by At

How can we conditionally append "index.html" to a request for a url that ends in a slash?

As background: We deploy multiple static, single page apps for multiple domain names to a single S3 bucket with web hosting enabled. This bucket is available as: https://our-bucket-name.s3.amazonaws.com

The bucket is organized with object key prefix so that: https://our-bucket-name.s3.amazonaws.com/environment/app_name/build_id/index.html https://our-bucket-name.s3.amazonaws.com/environment/app_name/build_id/app.css https://our-bucket-name.s3.amazonaws.com/environment/app_name/build_id/app.js

If there is a request for: https://www.example.com/ This should be routed to: https://our-bucket-name.s3.amazonaws.com/environment/app-name/build_id/index.html

If there is a request for: https://www.example.com/app.css This should be routed to: https://our-bucket-name.s3.amazonaws.com/environment/app-name/build_id/app.css

Not sure if it is relevant, but traefik here is for a kubernetes ingress that we want backed by AWS S3.

1

There are 1 answers

1
Ryan On BEST ANSWER

You could use AddPrefix or ReplacePath modifier, though you would also need to create a matcher on your fontend as well.

STEPS

  1. create front end to match blank path rule
  2. add modifier to that front end. ReplacePath should do the trick
  3. route to backend