Skip to content
Advertisement

Communicate between microservices on the same machine without exposing a public API

I am relatively new to Camel and Spring, and I am making a service to predict stock prices using a neural network to practise using Camel, Spring and also DL4J.

My service is divided into 5 microservices (Gateway, H2 SQL Database, Admin Console, Data Fetcher, DL4J Handler) which will each run in their own Java application. Each one has a REST API.

How can I prevent an external computer from connecting to 4 of the services, while leaving the gateway open and connectable?

To clarify:

All 5 services have a REST endpoint, and they are all visible to each other because they are all running on the same machine and can connect with localhost:port. I’d like to know how I can prevent an external computer from connecting to 4 of the services, whilst leaving 1 (the gateway) still connectable.

Advertisement

Answer

There’s nothing unique about Spring or Camel here.

Each one has an REST API, meaning there’s an HTTP endpoint, meaning each service has bound its server port on localhost, and so can reach each other via http://localhost:<port>, assuming nothing is running in a VM or Docker container

You should also be able to use the gateway on localhost

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement