本文基於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 # 安全的註冊地址