I have set up Zuul for routing and Eureka for service discovery, which works fine. Before setting up Eureka, I used server.address=127.0.0.1
to bind my actual service to localhost
so that they could only be accessed from within the Api gateway.
When combining Zuul and Eureka, server.address=127.0.0.1
does not work anymore. I cannot access my actual REST endpoints, neither from within my network nor from the outside.
application.properties of my Eureka service discovery:
spring.application.name=service-discovery
server.port=8761
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
application.properties of my Zuul API gateway:
spring.application.name=api-gateway
zuul.prefix=/api
server.port=8080
ribbon.eureka.enabled=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
zuul.routes.library.path=/library/**
zuul.routes.library.serviceId=library
application.properties of my actual REST service:
spring.application.name=library
server.servlet.context-path=/library
server.port=8090
server.address=127.0.0.1
ribbon.eureka.enabled=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
When I remove server.address=127.0.0.1
from the REST service's properties file, I can of course access the resource - But also from without localhost
, which is not what I want.
So what I try to achieve is that my little microservices can only be accessed from within localhost
(after the request has passed the Zuul API gateway). Furthermore I want to use Eureka for service discovery and for having the chance to provide second instances of serives.