Expsing mutple enpoinds - Api gateway(s)

Can | Should we expose many api endpoints on different IP addresses or Port in Lagom?

Hi @brabo-hi,

I don’t know if I understand your question. Each endpoint is a service that is exposed on it’s one IP address.

Can you clarify your question?

HI @renato thanks for taking time to answer my post.
As i said i have multiple api:
api1.myappp.com
ap2.myapp.com
ap3.myapp.com
They all have different endpoints, for example:
api1.myappp.com/login is differrent from ap2.myapp.com/login
My question is how can we expose those public apis on different ports in lagom ?
As i understood in lagom we can only expose one port (http://myIp:9000) in dev for example.
And my goal is to have:
http://myIp:9001 for api1.myappp.com
http://myIp:9002 for api2.myappp.com
http://myIp:9003 for api3.myappp.com

Yes, Lagom exposes the gateway for dev mode, but you can expose any service you want in production. That’s not something to solve in Lagom, but to solve in the gateway in production.

Btw, all services are already exposed in dev mode, they get ports assigned by Lagom. You can see them in the logs, but by accessing: http://127.0.0.1:9008/services

In production, you either expose all the services or you add a gateway and there is no port 9000 being exposed.

About exposing the services, that’s not a common practice, to be honest. You usually have different microservices deployed all using different deployments (number of nodes, memory, CPU) and one gateway on top of them all that expose the microservices as if they were one single application.

But again, nothing is blocking from open the doors and expose them directly.

And if you prefer you can assign fixed ports to your services in dev mode as well, check https://www.lagomframework.com/documentation/current/scala/ConfiguringServicesInDevelopment.html#How-are-ports-assigned-to-services

You can then assign the ports 9001, 9002, 9003. Note that if you want to use port 9008, you need to assign another one for the service locator. Check https://www.lagomframework.com/documentation/current/scala/ServiceLocator.html for more details.

1 Like