Webhook with localhost for Spring Cloud config - spring

I'm new with Spring cloud config and Spring cloud bus so I follow this topic to create my first Spring Cloud Config Server/Client using Spring Cloud Bus, Webhook to make Clients auto refresh when config change.
But I don't understand in step 4.3 . My config Server and Client are in localhost so what exactly is this url in my case?
http://root:s3cr3t#REMOTE_IP:8888/monitor
I tried but got this error:
URL 'http://REMOTE_IP:8888/monitor' is blocked: Host cannot be resolved or invalid
Sorry for my bad English!

Related

Spring Cloud Gateway Proxy Host issue

I am running Spring Cloud Gateway with Spring Boot version 2.5.8 and Spring Cloud version 2020.0.5.
I am trying to configure Spring Cloud Gateway to validate JWT access tokens using Spring Security and thus the gateway needs to connect to the OAuth2 Authorization server external to my company's network. As per company standard, I am using a proxy host to connect to the external Authorization server and I have set the http.proxy* and https.proxy* environment variables ie
-Dhttp.proxyHost=my-proxy.com -Dhttp.proxyPort=3328 -Dhttps.proxyHost=my-proxy..com -Dhttps.proxyPort=3328 -Dhttp.proxySet=true -Dhttps.proxySet=true
and well as the properties in application.yml. ie
spring:
cloud:
httpclient:
proxy:
host: my-proxy.com
port: 3328
But I am getting timeout error when connecting to the external Authorization Server. The proxy host and port are correct and are working for other Spring Boot projects using Spring MVC. I saw this question/answer
spring-boot app as spring-cloud-gateway has to use a proxy: JVM arguments not used NOR spring.cloud.gateway.httpclient.proxy.****
But my entries in application.yml is not working. Would appreciate if someone can provide some advice on resolving the issue.
Thanks

Spring Cloud Gateway on App engine is not routing the requests to downstream services

I am trying to deploy a simple microservice application (Spring boot) in GAE. The application has 3 services -
1. Discovery Service
2. Spring Cloud Gateway
3. Customer service
I am trying to call an API through API gateway. This works fine in local machine but getting 404 in GAE hosted application.
The URL I am using is - https://Gateway-url/customer-service/version
And corresponding YAML config is :
spring:
cloud:
gateway:
routes:
-id: customer-service
uri: https://XXXXXX.customer-service.appspot.com/
predicates:
- Path=/customer-service/**
filters:
- StripPrefix=1
The URI configured in above code snippet is - target URL of GAE service.
So When I hit the https://Gateway-url/customer-service/version url in browser, I am getting 404 error but it works if I hit the direct url https://customer-service-url/version
When I changed the API Gateway configuration in the local environment, (change uri to cloud based service uri), the issue is reproducible. So I am thinking that Gateway is not able to route the requests to App Engine Service target URL.
How can I fix this problem?
I think the problem is the url that you are using in the configuration file to route your requests.
According to google cloud documentation, to call from one service to another you should use a endpoint like this
https://VERSION_ID-dot-SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com
As yo can see here
https://cloud.google.com/appengine/docs/standard/java/communicating-between-services
And it seems that the url that you are using doesn't fit int this.
Anyway I think that in a serverless environment such as app engine the best option to perform service discovery and to route requests via gateway is using the services provided by google. In case of service discovery it is done automatically and if you want a gateway you can use google cloud endpoints that have a greate integration with app engine. Because this is the gateway intended to use with these applications

Spring Cloud Gateway with SSL cannot route to service by name

I had enable SSL on Spring Cloud Gateway service, and after that routing such as
.route("instruments-ui", r -> r.path("/instruments/**")
.filters(f -> f.filter(addCredentials.apply()).preserveHostHeader())
.uri("lb://instruments-ui"))
ceased normally working. If I change uri to real address such as http://localhost:8001 routing working right. I use Gateway version 2.0.0.RC1. Can anybody explain how to setup Spring Cloud Gateway + routing with Eureka data + SSL?
If your Gateway works with SSL and downstream services works without it, then you need to specify uri as for example .uri("lb:http://instruments-ui"). I found it after viewing LoadBalancerClientFilter class.

Turbine stream double port binding issue

I'm using Spring Boot 1.5.4 and Spring Cloud Dalston SR4 to stand up a Turbine server on Cloud Foundry and aggregate my application Hystrix streams. In addition I want to add Spring Boot Actuator monitoring and management to the Turbine server. I realize there is ample documentation on how to do this in a local environment and I do have it working locally. However it is a different matter when deploying to Cloud Foundry where I cannot use port numbers in a Url binding.
The issue is that the Turbine stream is provided by an RxNetty server on one port and the Actuator endpoints are provided by via Tomcat on another port. In Cloud Foundry I can only bind my Url to RxNetty endpoint or the Tomcat endpoint, not both.
No combination of management.port and turbine.stream.port allows me to access the turbine stream and the actuator endpoints from one host binding. The following is an example of what I would expect to be able to do:-
https://myapp.mydomain.com/info (to report actuator info details)
https://myapp.mydomain.com/turbine.stream (to stream turbine metrics)
Note: There are no port numbers in these Urls.
Requests to your app on Cloud Foundry go through the Cloud Foundry Go Router, which uses the http host header to direct traffic to all the container instances running your app. The http based gorouter expecter only one port to be opened by the app to forward http traffic to. However, the gorouter also support tcp routing which should allow you to have multiple ports open. see the docsfor an explanation of tcp vs. http routes on cloud foundry.
If you are running on Pivotal Cloud Foundry you can use the Circuit Breaker Dashboard provided by Spring Cloud Serviecs for PCF then you won't need to setup the turbine stream. The Spring Cloud Services Dashboard uses RabbitMQ instead of SSE events see SCS docs for details
Just getting back to this now. As noted by spencergibb, moving to springboot 2.0 and cloud Finchley works.

Spring Cloud Config Server + RabbitMQ

I created spring cloud config server and client and they work as expected. I have added #RefreshScope to my client and I am able to see the new properties getting fetched after hitting /refresh endpoint. But I was told that when I deploy it in cloud foundry environment , I must integrate it with RabbitMQ in order for all the instances to receive the refresh message. Is it possible to point me to a link which explains this problem and solution in detail?
Spring Cloud Bus
This is what you need in order to propagate configuration changes to all of your servers via a message broker such as RabbitMQ.
GitHub Project
Documentation
Follow the instructions in the links above you're good to go.
So I assume your application runs as single instance configuration. In that case, you don't need spring cloud bus based refresh and just hitting the {app}/actuator/refresh would be enough. Only if you scale out your app, we would need such setup with a queue like RabbitMQ or kakfa.

Resources