springboot cloud Gateway routes to http - https

I successfully configured HTTPS for my springboot cloud gateway.
But routing is not working after changing to https. Its working fine with http.
my microservices clients are running in http.
This is my config file application.yml
server:
port: 8443
ssl:
enabled: true
key-store: classpath:atest.p12
key-store-password: XXXXXXXXXXXX
key-store-type: PKCS12
eureka:
client:
register-with-eureka: true
serviceUrl:
defaultZone : http://localhost:8761/eureka
spring:
application:
name: gateway_service
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: test_unique
uri: http://localhost:8081/test/v1/unique/
predicates:
- Path=/test/v1/unique/
Could you please help me to invoke microservice client (http) - uri: http://localhost:8081/test/v1/unique/

Related

Deploy spring boot microservices to heroku

I am trying to deploy my microservices to heroku but without success. At first I created application for service registry (eureka) with following configuration:
spring:
application:
name: eureka
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Next I deploy application, url of deployed app is like https://eureka.herokuapp.com. I configure with this url my other apps like gateway and business services.
Example of my gateway configuration
spring:
application:
name: gateway
server:
port: 8081
eureka:
client:
healthcheck:
enabled: true
serviceUrl:
defaultZone: https://eureka.herokuapp.com/eureka/
same configuration I used for my user service, just different app name (user-service). When I go to https://gateway.herokuapp.com/user-service/user I cannot receive any response. In heroku logs of gateway app I can see exception because of timeout of user service which I don't understand because when I call https://user.herokuapp.com/user directly I get response
I also find out in my eureka dashboard is not registered replicas, I am not sure if it ok. Can you tell me what I did wrong? Thank you.
error log from gateway app:
2019-12-01T19:53:29.503419+00:00 heroku[router]: at=info method=GET
path="/user-service/user" host=gateway.herokuapp.com
request_id=7818f5eb-34af-47f9-94db-7dc4f9609c31 fwd="86.49.253.78"
dyno=web.1 connect=0ms service=8110ms status=500 bytes=465
protocol=https
Your gateway configuration missing gateway discovery section. Also registry does not require "serviceUrl"
Try bellow configuration
registry
spring:
application:
name: eureka
server:
port: 8761
eureka:
instance:
prefer-ip-address: false
client:
register-with-eureka: false
fetch-registry: false
Gateway
spring:
application:
name: gateway
cloud:
discovery:
enabled: true
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
server:
port: 8081
eureka:
client:
fetch-registry: true
register-with-eureka: true
healthcheck:
enabled: true
serviceUrl:
defaultZone: https://eureka.herokuapp.com/eureka/

Spring-Cloud on Weblogic 12.1.2

We have developed Spring-boot microservices with NetFlix OSS/Spring-cloud. In the development environment, we are running with embedded tomcat, it works well.
Now I'm trying to deploy on Weblogic 12.1.2, I'm able to deploy service registry and API-Gateway inside two different managed servers. But When I open Eureka server page, API-Gateway is not registered with the Service Registry.
Service-Registry application.yml
spring:
application:
name: service-registry
server:
port: 61001
eureka:
client:
register-with-eureka: false
fetch-registry: false
api-gateway application.yml
spring:
application:
name: api-gateway
cloud:
loadbalancer:
retry:
enabled: true
# Ribbon - Client side load balancer
ribbon:
ReadTimeout : 60000
ConnectTimeout: 60000
server:
port: 61002
context-path: /nasw
eureka:
client:
serviceUrl:
defaultZone: http://<ipAdr>:61001/eureka/
# instance:
# instanceId:
### Zuul - Router/Filter/Reverse Proxy
zuul:
ignoredServices: '*'
host:
connect-timeout-millis: 100000
socket-timeout-millis: 600000
routes:
network-planning: "**/network-planning/**"
network-schemagen: "**/network-schemagen/**"
network-verification: "**/network-verification/**"
nw-netgeoview-nw-tracer: "**/nw-netgeoview-nw-tracer/**"
### Hystrix - Circuit Breaker/Fault&Latency Tolerant
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 600000
timeout:
enabled: false
isolation:
strategy: SEMAPHORE
Service registry home page
Could you please help me with following queries?
Is it possible to deploy Spring-Cloud on Weblogic 12.1.2?
Is it a correct way to deploy each microservice in a separate managed server?
If Yes, Am I missing any configuration so that api-gateway can register with service-registry?

Config server and eureka server in same application: tries to connect to localhost:8761

I have a spring-boot application which I use to setup a spring cloud config server and a eureka server in development and testing environments.
Strangely the application always tries to connect to localhost:8761, even though I have eureka.client.registerWithEureka set to false.
How can I deactivate this?
The error:
ERROR 3144 --- [et_localhost-12] c.n.e.cluster.ReplicationTaskProcessor : Network level connection to peer localhost; retrying after delay
com.sun.jersey.api.client.ClientHandlerException: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.4.10.jar:1.4.10]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.10.jar:1.4.10]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.4.10.jar:1.4.10]
at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:71) ~[eureka-core-1.4.10.jar:1.4.10]
at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.4.10.jar:1.4.10]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92]
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
My only class looks like this:
#EnableEurekaServer
#EnableConfigServer
#SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
The application.yml:
server:
port: 8888
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
renewal-percent-threshold: 0.49
security:
basic:
enabled: true
user:
password: mypassword
spring:
jmx:
default-domain: ${spring.application.name}
cloud:
config:
server:
git:
uri: https://example.com/myrepo.git
username: username
password: password
clone-on-start: true
search-paths: '{application},{application}/{profile}'
endpoints:
jmx:
domain: ${spring.application.name}
unique-names: true
In the bootstrap.yml I have only the application name set.
Versions:
spring-cloud-netflix-eureka: 1.1.6,
spring-cloud-config-server: 1.1.3
Could you try to change your configuration like below
eureka:
client:
registerWithEureka: false
fetchRegistry: false
service-url:
defaultZone: http://localhost:8888/eureka
You specify server.port: 8888. So your eureka is running on 8888 port. But you didn't specify any service-url for eureka. So I think that your eureka server is trying to replicate to localhost:8761 because it's default and you didn't specify service-url for eureka.
For me, below properties that worked for me.
eureka.client.registerWithEureka= false
eureka.client.fetchRegistry= false
eureka.server.maxThreadsForPeerReplication=0
Please Use 8761 port for your Eureka server as below.
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
Here we’re configuring an application port – 8761 is the default one for Eureka servers. We are telling the built-in Eureka Client not to register with ‘itself’, because our application should be acting as a server.
It seems that eureka tries to connect to itself despite the below settings:
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
you have two options to fix that 1-Keep the default port of eureka 2-Add below to your application.properties of your eureka server eureka.server.maxThreadsForPeerReplication=0

ZuulException: forward error with Zuul-Eureka

I'm facing a ZuulException: forward error when routing with Zuul and Eureka.
The error not occur during the first minutes but after 1 or 2 mn I get this weird error.
I'm using spring boot 1.4 and spring cloud Camden
If you want to reproduce the error or see my project: https://github.com/Seb69/Spring-demo-ZuulException/tree/master
Eureka config:
server:
port: 9999
spring:
application:
name: eureka-server
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Service-Gateway config (Zuul):
server:
port: 1111
spring:
application:
name: service-gateway
# ZUUL (Load balancing)
zuul:
ignoredServices: '*'
routes:
service-server:
stripPrefix: true
path: /api/**
serviceId: SERVICE-SERVER
# EUREKA (Service registry)
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
Service config:
server:
port: 8095
spring:
application:
name: service-server
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
Here is a short version of my stack trace:
com.netflix.zuul.exception.ZuulException: Forwarding error
Caused by: com.netflix.client.ClientException: Number of retries on
next server exceeded max 1 retries, while making a call for:
mbp-de-andre:8095
Caused by: java.net.UnknownHostException: mbp-de-andre
FIX:
So, I finaly succeed to make it work !
My problem came from my Macbook Hostname,
Last hostname was: mbp-de-andre
I modify it and I set: `MacBook-Pro-de-ANDRE.local``
Just want to say another fix might be missing dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>

consul health check: 503 Service Unavailable

I'm using spring cloud consul in my application. when I started the application I have no exception (service Registed in consul). but when consul check health I got this error:
HTTP GET https://xxxxxxxxxx:8181/health: 503 Service Unavailable Output: {
"status" : "DOWN"
}
Here is my configuration file:
spring:
application:
name: #pom.artifactId#
cloud:
config:
enabled: false
consul:
config:
enabled: true
host: localhost
port: 8500
discovery:
scheme: https
endpoints:
health:
sensitive: false
restart:
enabled: true
shutdown:
enabled: true
my pom is as follow:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>1.0.0.M6</version>
</dependency>
It looks like your configuration is a little bit incorrect.
The latest documentation contains the following configuration example:
spring:
cloud:
consul:
host: localhost
port: 8500
BTW: The latest spring-cloud-consul version is RC1

Resources