Traefik equivalant of Nginx's X-Accel-Redirect?

Hi all - I'm trying to switch a project of mine to Traefik, but there's part that I haven't found in the docs.

I have certain files that need to be served but only conditionally, based on a permissions scheme in my Django app. E.g. serve certain files only to specific logged in users, serve other files to anonymous users.

With Nginx, this is the solution that I'd follow: https://wellfire.co/learn/nginx-django-x-accel-redirects/

How would I implement a similar solution in Traefik and docker+docker-compose?

Many thanks!

2 Likes

Hi,
Have you find a working solution ?

Interesting feature of nginx. Not sure such a function exists with Traefik.

You could redirect the client to a real file URL (maybe with short-time valid token in query) and protect the URL with ForwardAuth middleware. It would generate a second request to your app, but you don’t have to deliver the file through your app.

Having this feature would be a great improvement over having to run nginx or Apache.