0

I have a Spring Boot web application that I'd like to split up into about six separate applications; one would provide the homepage and login at endpoints under "/", and the others would each claim a subdirectory path ("/subsystem1", "/subsystem2", etc...). I have a pretty clear idea how I could use JWT to pass authentication/authorization from the login app to the others.

The main reason for this is so that each subsystem can be modified or updated without shutting down the others. And organizationally, so we don't have to subject the entire app to a QA process when only one subsystem is changed.

Is it possible to set up multiple Spring Boot instances to run on the same server at the same time and the same port, with different paths/directories to their endpoints? How?

I was unable to find any duplicate question, but here are two related questions that may offer clues:

Acceptable answers:

If, as ekalin suggests, it is impossible to have multiple Spring Boot apps listen to the same port, here are a couple of ideas I have brainstormed (but don't know how to accomplish):

  • Perhaps the instances could be running on different ports but the main app (the one with the login page) could "forward" or redirect to the other apps in some way that hides their true URLs? E.g. "localhost:8080/subsystem1" would be an alias for "localhost:8081/".

  • Perhaps the applications could each have their own Docker containers, all running within a shared Docker network, and we use Docker somehow to map each URL path to the right app? Could this be set up with docker-compose?

  • We set up a proxy server of some kind that remaps URL paths to the separate applications.

workerjoe
  • 2,421
  • 1
  • 26
  • 49

1 Answers1

2

You can't have more than one application listening on a port. How would the kernel which application to send the packages to?

You could run an http server such as nginx listening on 8080, and each application in a different port, and then proxy the requests based on the URL to the desired application.

ekalin
  • 872
  • 7
  • 19
  • The proxy server idea: seems straightforward but I've never done that before. Can you suggest a tool or something to read to get me started? – workerjoe Jan 31 '20 at 18:50
  • nginx is probably the most popular and easier to setup, but apache should work as well. Or any other http server with reverse proxy support. – ekalin Jan 31 '20 at 19:56
  • https://www.garron.me/en/linux/nginx-reverse-proxy.html shows the basic configuration for this case. – ekalin Jan 31 '20 at 19:59