navaltiger
navaltiger

Reputation: 883

Multiple spring boot inside docker container

We are playing with docker and spring boot, and quite new to that ..

Here is our use case :

* There are three Spring Boot based web applications 
  - web1 = works on port 8010 = exposes API as http://...:8010/web1/rest/someEndPoint_1
  - web2 = works on port 8020 = exposes API as http://...:8020/web2/rest/someEndPoint_2 
  - web3 = works on port 8030 = exposes API as http://...:8030/web3/rest/someEndPoint_3

* All of these should be packaged in single docker image 
* Docker may have apache/haproxy/nginx and it should expose port 8080, which 

will be mapped to host's port at 8080

* Here is requirement : 

  - If request will come to Docker as http://DOCKER_HOST_IP:8080/web1/rest/someEndPoint_1 
        ==> host will forward traffic to container 
        ==> Proxy running inside container will see pattern 
        ==> http://...:8010/web1/rest/someEndPoint_1

  - If request will come to Docker as http://DOCKER_HOST_IP:8080/web2/rest/someEndPoint_1 
        ==> host will forward traffic to container 
        ==> Proxy running inside container will see pattern 
        ==> http://...:8020/web2/rest/someEndPoint_1

  - If request will come to Docker as http://DOCKER_HOST_IP:8080/web3/rest/someEndPoint_1 
        ==> host will forward traffic to container 
        ==> Proxy running inside container will see pattern 
        ==> http://...:8030/web3/rest/someEndPoint_1

Is it possible to achieve? (Basically we are asked to check if routing traffic based on URL pattern is possible or not?)

Please feel free to add comments/edit question! Thanks and advance. Regards..

Upvotes: 1

Views: 343

Answers (1)

Tomasz Bawor
Tomasz Bawor

Reputation: 1647

You are looking for API gateway that will be routing request incoming to one point to diffrent services. You should take a look at Spring Cloud Gateway and see whether this will satisfy your needs.

Configuration should be very simple, you will expose your gateway on port 8080 and configure proper routings to all of your services.

After that you will be able to aggregate all apis under one ip:port

More information can be found on cloud gateway tutorial.

Upvotes: 2

Related Questions