Pratik Daigavane
Pratik Daigavane

Reputation: 73

TraefIk Forward Auth Request URI

I am using Traefik's Foward Auth middleware to authenticate my requests.

The auth server is hosted at http://localhost/auth The requests that I want to authenticate are from http://rooms.localhost/:roomId

For example, http://rooms.localhost/ed455783-1502-4c9e-a403-28e621d77fb4?token=qwerty is my request URL. Now the URL is forwarded to the auth server for authentication. But at the auth server, I am not able to see the requested URL or header like X-Forwarded-URI.

The headers which I can see are

{
host: 'localhost',
'user-agent': 'PostmanRuntime/7.26.3',
 accept: '*/*',
 'accept-encoding': 'gzip, deflate, br',
x-forwarded-for': '127.0.0.1',
'x-forwarded-host': 'localhost',
'x-forwarded-port': '80',
'x-forwarded-prefix': '/faa054d5-0fe3-435e-83cb-9b817177d495',
'x-forwarded-proto': 'http',
'x-forwarded-server': 'b35a8676b5a8',
'x-real-ip': '127.0.0.1'
}

So how should I get the requested URI in order to access the token?

Note that passing token in cookies or headers is not an option for me because the WebSocket connections are also needed to be authenticated.

Following are my traefik labels

- traefik.http.middlewares.faa054d5-0fe3-435e-83cb-9b817177d495-auth.forwardauth.address:   http://localhost/auth
- traefik.http.middlewares.faa054d5-0fe3-435e-83cb-9b817177d495-stripprefix.stripprefix.prefixes:   /faa054d5-0fe3-435e-83cb-9b817177d495
- traefik.http.routers.faa054d5-0fe3-435e-83cb-9b817177d495.middlewares:    faa054d5-0fe3-435e-83cb-9b817177d495-stripprefix, faa054d5-0fe3-435e-83cb-9b817177d495-auth
- traefik.http.routers.faa054d5-0fe3-435e-83cb-9b817177d495.rule:   Host(`rooms.localhost`) && PathPrefix(`/faa054d5-0fe3-435e-83cb-9b817177d495`)

Upvotes: 3

Views: 2148

Answers (1)

Pratik Daigavane
Pratik Daigavane

Reputation: 73

I was able to solve this problem using

--entryPoints.web.address=:80 
--entryPoints.web.forwardedHeaders.insecure

Upvotes: 3

Related Questions