本文基于SpringCloud-Dalston.SR5spring
通常的,Eureka在内网服务,咱们不会对于外网暴露Eureka端口,因此通常Eureka不作任何验证。假设咱们想进一步加强Eureka的安全性,能够结合spring security
来简单配置一些安全设置安全
首先在Spring Cloud Eureka Server所在的项目中添加对于spring security
的依赖:app
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
而后在项目配置文件application.properties
中加入安全认证,注意三点配置,用户名,密码,还有Eureka服务地址:spring-boot
#打开security security.basic.enabled=true security.user.name=username security.user.password=password #这里的用户名密码就是上面配置的 eureka.client.service-url.defaultZone=http://username:password@localhost:8761/eureka # 安全的注册地址