2
votes

I have a Eureka Server running on default localhost host and port 8761, so i tried to change this default configuration in this way:

server:
  port: 6000
  servlet:
    context-path: /myeureka
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

But in this way i can't access eureka dashboard, just using default configuration:

server:
  port: 8761
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

In my client same thing occurrs, i can't point to another eureka server different from default (localhost:8761), see my configuration:

server:
  port: 7000
  servlet:
    context-path: /client-eureka
spring:
  application:
    name: client-eureka
eureka:
  instance:
    prefer-ip-address: true
  client:
    eureka-server-port: 6000
    eureka-server-u-r-l-context: /myeureka

Lookin in client log i got the following:

2018-09-01 09:19:37.175  INFO 4931 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://localhost:8761/eureka/

No matter what port or host i configure in client, always try to reach the default.

Important: I'm using eureka in this version: https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server/2.0.1.RELEASE

1

1 Answers

6
votes

I used the same dependency version as yours and cannot find the config path server.servlet.contextpath

Instead, you can use either server.servlet-path or server.context-path

With each of the server configuration, you need to update your client application.yml file too. Remember that /eureka is the default REST endpoint used to register Eureka client with Eureka server

Case 1: Use server.servlet-path

Eureka Server:

server:
 port: 7000
 servlet-path: /myeureka

eureka:
 client:
   register-with-eureka: false
   fetch-registry: false

Eureka Client:

spring:
  application:
    name: spring-cloud-eureka-client
server:
  port: 0
eureka:
 client:
   service-url:
     defaultZone: ${EUREKA_URI:http://localhost:7000/eureka}
 instance:
     preferIpAddress: true

Case 2: Use server.context-path

Eureka Server:

server:
 port: 7000
 context-path: /myeureka

eureka:
 client:
   register-with-eureka: false
   fetch-registry: false

Eureka Client:

spring:
  application:
    name: spring-cloud-eureka-client
server:
  port: 0
eureka:
 client:
   service-url:
     defaultZone: ${EUREKA_URI:http://localhost:7000/myeureka/eureka}
 instance:
     preferIpAddress: true

Updated answer: Because server.servlet-path and server.context-path were deprecated, eureka server will be configured as following:

server:
 port: 7000
 servlet:
   context-path: /myeureka

eureka:
 client:
   register-with-eureka: false
   fetch-registry: false

Eureka client application.yml will be kept as in Case 2.