1

I have a domain. Let's say test.com. I have to forward requests of a route of this domain to a subdomain and render response of the same without Changing URL via Caddy Server For Example,

Request Flow: test.com/home -> Caddy -> https://demo.test.com/home

Response Flow: test.com/home <- Caddy <- https://demo.test.com/home

I tried following reverse_proxy rules to achieve this but was unable to achieve the desired response.

test.com {
     reverse_proxy /home https://demo.test.com/home {
                #proxy to subdomain
                header_up Host demo.test.com
     }
}

This crashes the whole site. I think the reason for this is that Caddy doesn't support such type of Upstream Addresses. Valid addresses can be seen here.

Then, I tried the valid one -

test.com {
     reverse_proxy /home https://demo.test.com {
                #proxy to subdomain
                header_up Host demo.test.com
     }
}

This didn't led to any error but this didn't bring me any response either. The reason for this can be that I am forwarding the request from Client to another Client and not the actual server.

Hence, I tried to hit the IP address associated with the sub domain

test.com {
     reverse_proxy /home <IP-address> {
                #proxy to subdomain
                header_up Host demo.test.com
     }
}

This changes the actual route i.e. in the web-browser it changes the URL from test.com/home to demo.test.com. But it doesn't brought any response either.

Kindly comment if there is any possible solution for forwarding the request to a sub-domain route. If the solution is not supported by Caddy but by another Web Server, that will also be helpful.

Shobit Jain
  • 308
  • 2
  • 14

0 Answers0