I have deployed two tomcats on my host on different ports. one is listening on port A and one on port B. There are webapps hosted on both the tomcats.
I need to make sure that the client which calls APIS on those webapps on both tomcats doesn't need to know both the ports. The client (angularJS) should be able to call just one tomcat and internally that tomcat should be able to redirect the request for proper service to another tomcat and pass the response back to the client.
That way I will be able to handle same origin policy also as the angularjs webapp is also deployed on the tomcat where I want to send the requests and cookies can also be used with this as there will be only one server where the cookies will be coming from.
Is there any way to achieve that? Is there any configuration that I can do on the first tomcat itself to redirect some request based on the URI to the second tomcat? or any other tool that I can deploy to support that? I heard somewhere of port redirection using iptables. Can that be used here?