0

I have a system that uses multiple subdomains. I want to deploy them within at least a Docker Compose setting, or maybe a Swarm.

Reverse Proxy is the only container with Ports open on the host. All calls go through it. It's nginx.

The client can call either subdomains directly. The first subdomain may call the second. In the case at hand, Web App may call API. When the client calls, the HTTP request has the FQN along with the protocol and port. So the client may call, http://sub2.my.tld/services/accounts/. This service will return a list of accounts. Each account is a hypermedia document with a 'self' link. When the client call, the self like is 'http://sub2.my.tld/services/accounts/{n}'. This allows the client to call for a specific account. Nothing earth shattering is here.

When Web App makes the same call, it doesn't use the FQN. Instead it uses http://api/services/accounts. Web App might then render that list in a nice HTML page. Unfortunately the context path (Java/Spring MVC) in API returns the self link as 'http://api/services/accounts/{n}'. When the HTML goes to Client the link is now unaccessible. If Web App attempts to call 'http://sub2.my.tld/services/accounts', it can't find that host.

Internally, API uses ServletUriComponentsBuilder.fromCurrentContextPath() to create the URI for self (and others).

Presently I have all of these setup through Docker Compose. My ultimate goal is to have 3 instances of API and Web App running. How do I get Docker to do this? The ???? shows where I'm confused.

General Deployment Context

Virmundi
  • 2,497
  • 3
  • 25
  • 34
  • Possible duplicate of [How to configure Spring HATEOAS behind proxy?](https://stackoverflow.com/questions/30020188/how-to-configure-spring-hateoas-behind-proxy) – David Maze Jul 27 '18 at 21:05
  • (This isn't at all Docker-specific, you have the same problem if you're accessing the proxy via an internal hostname behind a firewall.) – David Maze Jul 27 '18 at 21:06
  • Where I think this is Docker specific is naming the containers. I can directly address Web App and API from the client. – Virmundi Jul 29 '18 at 04:11

0 Answers0