Given I have multiple web applications running in docker containers, I want to be able to let the user be redirected from on service to another service in his browser. I wonder how to achieve this - especially if I want my applications to be portable from one docker host to a different host.
Let's say we have a ServiceA which redirects the user to ServiceB. So we have a relationship
ServiceA --> ServiceB
One approach would be to statically assign ports and hostnames and set them as environment vars to my web services - which I would not prefer because I don't want to care about which service runs on which port.
A second approach would be to have a proxy like nginx and link the services and use the proxy host and port. But this would require to change the proxy configuration when moving a service to a different host.
The third approach that comes to mind, is to use etcd and ambassadors to register and resolve services. So ServiceA would use a ServiceB-Ambassador which looks up ServiceB in etcd. This results in many docker containers just to connect between services.
Which way would you prefer? Or are there different approaches?
Edit
The real problem is to inject the uri of ServiceB into ServiceA, so I can launch my ServiceA with an argument like -DserviceB.uri=<serviceUri>
, so that serviceA can build the correct redirect header.