(Caddy v2)Can I add basic auth for redir?

example.com {
                basicauth /* {
*** ******
                }
                redir https://a2.example.com
}

It seems that basicauth is not valid for redir.

What you’re running into is due to the default directive order in Caddy:

You’ll notice that redir is higher on the list than basicauth.

To do what you want, the best way to fix it is to wrap those directives with a route which lets you override the order in which directives within it will be handled.

example.com {
	route {
		basicauth {
			*** ******
		}
		redir https://a2.example.com
	}
}

Next time, please fill out the thread template. It’s important for us to help you.

3 Likes

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