spring-cloud / spring-cloud/spring-cloud-gateway
Filter to change scheme and apply it to discovery integration.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
I have a cloud-gateway enabled service discovery with consul using https, a http service and a https service both registered to consul for test. Gateway worked fine when it(https) redirect to https service, but failed when redirecting to http. Here is the exception:
io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record
I also changed my gateway to http, and this time it turned to fail while proxying http to https.
I googled this exception, it seems it's caused by accessing a http resource using https. I found some solutions in other issues, like adding a https2http convert filter or specifying the exact route redirecting https url to http url. The former needs other micro services to be either all https or all http, while the latter does not using auto-discovery, they cannot solve my question very well.
As I have registered my services to consul annoucing scheme as http/https, and I can find my service with [secure=true] and [secure=false] tags in consul-ui, so I guess cloud-gateway can tell which service is using https and which is http. I wonder is there a way to config cloud-gateway to auto redict to https and http service using consul discovery?
my gateway configuration (https):
spring:
application:
name: gateway
cloud:
gateway:
discovery:
locator:
enable: true
httpclient:
ssl:
use-insecure-trust-manager: true
consul:
host: localhost
port: 8500
discovery:
register: false
server:
port: 10090
ssl:
enabled: true
key-store: classpath:keystore.p12
key-store-password: tomcat
key-store-type: PKCS12
key-alias: tomcat
service1 configuration (http):
spring:
application:
name: service1
cloud:
consul:
host: localhost
port: 8500
discovery:
health-check-interval: 15s
instanceId: service1
health-check-tls-skip-verify: true
scheme: http
server:
port: 10091
service2 configuration (https):
spring:
application:
name: service2
cloud:
consul:
host: localhost
port: 8500
discovery:
health-check-interval: 15s
instance-id: service2
health-check-tls-skip-verify: true
scheme: https
server:
port: 10092
ssl:
key-store: classpath:keystore.p12
key-store-password: tomcat
key-store-type: PKCS12
key-alias: tomcat
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing discovery.locator route creation and how the Consul discovery scheme is carried into the gateway's target URI, using the provided HTTP and HTTPS service configurations to reproduce the failure. Done means an auto-discovered HTTP service is proxied over HTTP and an HTTPS service over HTTPS without requiring per-route filters or manual routes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100