Redirect to reverse proxy error in the caddyfile

1. Output of caddy version:

v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=

2. How I run Caddy:

.\caddy.exe run --config .\Caddyfile

a. System environment:

Windows

b. Command:

.\caddy.exe run --config .\Caddyfile

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->

d. My complete Caddy config:

{
	debug
}
localhost {
	forward_auth /auth/* localhost:8001 {
		uri /login/check
		copy_headers X-User X-Forwarded-Uri
	}
	route /desauth/* {
		uri /login/sign-out
	}
	
	reverse_proxy /login/* localhost:8001
	root * ./resources
	file_server {
		index /homepage.html
	}
}

3. The problem I’m having:

i add the route part of my configs to redirect every thinks that is in desauth to the login/sign-out that will trigger the reverse proxy but it doesn’t work i read all the document about uri and route but i don’t understand what i doing wrong

4. Error messages and/or full log output:

2022/09/30 15:32:30.605 INFO    using provided configuration    {"config_file": ".\\Caddyfile", "config_adapter": ""}
Error: adapting config using caddyfile: parsing caddyfile tokens for 'route': .\Caddyfile:12 - Error during parsing: parsing caddyfile tokens for 'uri': .\Caddyfile:11 - Error during parsing: Wrong argument count or unexpected line ending after 'uri'

5. What I already tried:

i try a redir and handle and add the reverse proxy inside of the route

6. Links to relevant resources:

the proxy is written in python, i modify a litlle bit of python3-experiments/caddy-server-auth at main · tonyallan/python3-experiments · GitHub

The second token (/login/sign-out) is treated as a path matcher; and you’re missing the operation to perform on the URI:

You need one of strip_prefix, strip_suffix, replace, or path_regexp.

1 Like

hi
thx for your fast answer i change the to uri replace /desauth/* /login/sign-out
now the server start but the route doesn’t match the path given ( route /desauth/*)
i thinks i missing somethings
have a nice day

This topic was automatically closed after 30 days. New replies are no longer allowed.