Forward hard-coded basic auth to some service?

Hello there,

Say that I have a service X exposed as http://10.0.10.123:5000 with basic authentication on machine A. Then, on machine B, I have Traefik (installed in Docker) where I manage all my routers for all services on multiple machines.

Is it possible for me to define a route like service-x.example.com, point to a service-x that proxies to http://10.0.10.123:5000, and automatically forwards the basic authentication username/password to that service? In other words, accessing service-x.example.com should automatically login the user to service X, without asking the user for a username/password (these would have to be hard-coded somewhere in Traeifk config).

I understand this might sound like an odd request, but please, humour me, is this even possible to achieve with Traefik? If so, can I get some pointers on how to do it?

Hello @rfgamaral,

It may not work, but you should be able to use the headers middleware to add an Authorization request header with your credentials encoded inside. Some details of how the header should be constructed may be found here: (Authorization - HTTP | MDN).

Then you could add the headers middleware to your router that you have configured to proxy to your backed service.

Awesome, that worked exactly as I expected. Thank you so much!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.