charon-spring-boot-starter icon indicating copy to clipboard operation
charon-spring-boot-starter copied to clipboard

Ability to map by host pattern instead of just path

Open jwgmeligmeyling opened this issue 4 years ago • 6 comments
trafficstars

Use case: reverse proxy differently for various requested hosts.

Example syntax:

charonConfiguration()
   // ...
   .add(requestMapping().hostRegex("subdomain\..*").set(...))
   .add(requestMapping().hostRegex("subdomain2\..*").set(...))

jwgmeligmeyling avatar May 28 '21 18:05 jwgmeligmeyling

Why do you need such feature?

mkopylec avatar May 31 '21 11:05 mkopylec

I'm using Bloomreach CMS which uses 2 different applications that need to be deployed on an application server. These applications need to be deployed under specific context paths (/site and /cms respectively). Of course no one wants to deploy their site at /site, so you need to reverse proxy this. However, Bloomreach went all their way to make it impossible to efficiently host this stuff. So after you made the site available at contoso.com/ , contoso.com/cms still won't work fully. Instead, you need to bind it under cms.contoso.com and have a reverse proxy for that as well.

Because of all the reverse proxy hell required to get Bloomreach too work (goes much beyond the standard capabilities of a load balancer like AWS EC2's one), I've decided to just deploy one extra WAR into the container with the reverse proxies for both the site and CMS. For this I need to be able to use different proxy configurations for different requested hostnames.

jwgmeligmeyling avatar May 31 '21 20:05 jwgmeligmeyling

Ok. Will you manually set the Host HTTP header in HTTP client when sending request to server that uses Charon? Is it even possible?

mkopylec avatar Jun 01 '21 09:06 mkopylec

To be more clear. What I see is:

Client -> Charon app (running behind some IP/domain) -> Outgoing servers (running behind some IP/domain)

Now, if you want the charon app to receive requests with Host header different than its IP/domain, you must set the header manually.

mkopylec avatar Jun 01 '21 10:06 mkopylec

The client connects through a browser, which specifies the requested host as part of the Request URL.

So both cms.contoso.com and contoso.com resolve to the proxy IP running the Charon app. Based on the requested host (set by the browser in the request URL), the proxy forwards the request to the appropiate URL.

jwgmeligmeyling avatar Jun 01 '21 12:06 jwgmeligmeyling

Ok, I see the point now.

mkopylec avatar Jun 01 '21 17:06 mkopylec