spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.5k stars 3.3k forks source link

Gateway resolving to http endpoints when microservice is https enabled #3491

Open KrishnaST opened 1 month ago

KrishnaST commented 1 month ago

Microservice 'IMPS-BENEFICIARY-SERVICE' is https enabled. Not sure if the issue with eureka discovery mechanism or the gateway.

RoutePredicateHandlerMapping.lambda$getHandlerInternal$0(94) Mapping [Exchange: POST https://127.0.0.1/imps/ReqPay/2.0/urn:txnid:DTYabf72ee5d7cd4d7c8d455cf377bf5d21] to Route{id='issuer_request', uri=lb://IMPS-BENEFICIARY-SERVICE, order=0, predicate=Paths: [/imps/Req**/**], match trailing slash: true, gatewayFilters=[], metadata={}}
ReactiveLoadBalancerClientFilter.filter(108) ReactiveLoadBalancerClientFilter url before: lb://IMPS-BENEFICIARY-SERVICE/imps/ReqPay/2.0/urn:txnid:DTYabf72ee5d7cd4d7c8d455cf377bf5d21
ReactiveLoadBalancerClientFilter.lambda$filter$2(143) LoadBalancerClientFilter url chosen: http://192.168.0.4:47229/imps/ReqPay/2.0/urn:txnid:DTYabf72ee5d7cd4d7c8d455cf377bf5d21
spencergibb commented 1 month ago

What discovery system are you using? What versions? What is your configuration?

KrishnaST commented 1 month ago

Discovery Server spring-cloud-starter-netflix-eureka-server : 4.1.2

Gateway Dependencies

Spring Boot : 3.3.2
spring-cloud-starter-gateway: 4.1.5
spring-cloud-starter-netflix-eureka-client : 4.1.3

MicroService Dependencies

Spring Boot Version : 3.3.2
spring-cloud-starter-netflix-eureka-client : 4.1.2

Microservice SSL configuration

server:
    ssl:
        key-alias: ****
        key-store: classpath:imps/ssl.pfx
        key-store-password: ***
        key-store-type: PKCS12
        enabled: true

Gateway Configuration

spring:
    application:
        name: gateway
    cloud:
        gateway:
            routes:
            -   id: issuer-route
                uri: lb://IMPS-BENEFICIARY-SERVICE
                predicates:
                -   Path=/imps/Req**/**
            discovery:
                locator:
                    enabled: true
                    lower-case-service-id: true
spencergibb commented 1 month ago

Please add the eureka configuration for the services

KrishnaST commented 1 month ago

Microservice Eureka Configuration

eureka:
    client:
        register-with-eureka: true
        fetch-registry: true
        serviceUrl:
            defaultZone: 'http://admin:password@localhost:8761/eureka/'
    instance:
        preferIpAddress: true
        instanceId: '${spring.application.name}:${random.int}'
KrishnaST commented 3 weeks ago

Resolved by setting 'secure-port-enabled' to true. Couldn't find this anywhere in documentation.

eureka:
    client:
        register-with-eureka: true
        fetch-registry: true
        serviceUrl:
            defaultZone: 'http://admin:password@localhost:8761/eureka/'
    instance:
        preferIpAddress: true
        instanceId: '${spring.application.name}:${random.int}'
        secure-port-enabled: true
        secure-port: ${server.port}
        status-page-url: https://${eureka.hostname}:${server.port}/actuator/info
        health-check-url: https://${eureka.hostname}:${server.port}/actuator/health
        home-page-url: https://${eureka.hostname}${server.port}/