Use Caddy to reverse_proxy from a url to specfific sub domain

1. Caddy version (caddy version):

v2.4.1

2. The problem I’m having:

Hello,

I try to do a particular setup that would look like this:

I have a domain for my website : subdomain.mywebsite.com

What I want is when someone goes to Home - Ownwebsite I would like to proxy it to
SpecificURL.domain.com with domain.com being always the same thing.

I tried to use caddyFile with reverse_proxy as the following without success.

:80 {
	reverse_proxy /(.*)) {
		to {1}.domain.com
	}
}

Is it possible to do such behavior and if yes It would be really nice if someone could point me into the right direction.

Thanks in advance

Guillaume

This should be possible by doing something like:

redir /specificURL https://SpecificURL.domain.com

Hi Paul,

Thanks for the answer. I would like to avoid the usage of redirection because in our infrastructure it would cause SSL issues (the upstream would be under azure cloud domain)

Did you try it like this?

:80 {
@specificURL {
      path /specificURL
        }

reverse_proxy @specificURL {
 // your proxy settings here
}
}

Hi Paul,

I will try this, but my asumption is that here the specificURL has to be “known” in advance, it’s not possible to extract the value and apply it dynamically to the reverse proxy right ?

Thanks.

If you want to use regexp, you must use a named matcher. Inline matchers can only be simple path matchers.

See the path_regexp matcher.

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