Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

microservices - How do remove context path from a service in spring cloud?

I have a spring eureka service on 192.168.3.8:8090. the config yml file is as follow:

server:
  port: 8090
spring:
  application:
    name: eureka-server

eureka:
  client:
    healthcheck:
      enabled: true
    registerWithEureka: false
    fetchRegistry: false
    service-url:
      defaultZone: http://192.168.3.8:8090/eureka

The gateway service config is as follow(The server Ip: 192.168.3.7):

server:
  port: 80
spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      discovery.locator:
        enabled: true
        lower-case-service-id: true
eureka:
  instance:
    prefer-ip-address: true
  client:
    service-url:
      defaultZone: http://192.168.3.8:8090/eureka
management:
  endpoint:
    gateway:
      enabled: true
    service-registry:
      enabled: true
  endpoints:
    web:
      exposure:
        include: gateway

And my app service is running at http://192.168.1.115:8090/Geoportal-Service-1.4.1. The config is as follow:

application:
  name: geoportal-service
server:
  port: 8090

eureka:
  client:
    service-url:
      defaultZone: http://192.168.3.8:8090/eureka
  instance:
    hostname: 192.168.1.115
    non-secure-port: ${server.port}
    prefer-ip-address: true
spring:
  cloud:
    config:
      discovery:
        enabled: true

A route example of Geoportal-Service-1.4.1 is http://192.168.1115:8090/Geoportal-Service-1.4.1/info. Now I can access this route from gateway in address http://192.168.3.7/geoportal-service/Geoportal-Service-1.4.1/info but I want to access it by address http://192.168.3.7/geoportal-service/info.

How can I fix this config?

question from:https://stackoverflow.com/questions/65643490/how-do-remove-context-path-from-a-service-in-spring-cloud

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...