I am working with Eureka/Zuul and Springboot microservices.
While mapping multiple instances of same application to Zuul gateway, i am using serviceId attribute.
Here i had shared my application.yml of zuul project.
server:
port: 8093
servlet:
context-path: /apigateway
spring:
application:
name: zuul-proxy
zuul:
sensitiveHeaders: Cookie,Set-Cookie
host:
socketTimeoutMillis: 60000
routes:
authenticator-oauth:
path: /oauth/
url: http://localhost:8092/authenticator/oauth
sample-resource-server:
path: /sample/
serviceId: sample
stripPrefix: false
sample:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: http://localhost:8096,http://localhost:8097
ConnectTimeout: 60000
ReadTimeout: 60000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100
authenticator:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: http://localhost:8092, http://localhost:8091
ConnectTimeout: 1000
ReadTimeout: 5000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8094/eureka/
instance:
preferIpAddress: true
I am able to run my authenticator application.
Also i am able to run my sample application on both port(8096/8097) with load balancing .
Here as you can see i had mapped authenticator service using URL and it's working fine.
url: http://localhost:8092/authenticator/oauth
But when i had mapped it with service id as below code, it's not able to redirect with actual authentication service url.
authenticator-oauth:
path: /authenticator/**
serviceId: authenticator
stripPrefix: false
In both these cases, i am hitting same URL as below
http://localhost:8093/apigateway/oauth/token.
Why authentication service or oauth/token end point behave differently compare to normal application?
Any help will appreciated.
In order to register multiple instance of same micro-service you have to do nothing
in ZUUL API GATEWAY.
Add a property in the micro-service itself for which you are creating multiple instance.
server:
port: ${PORT:0}
eureka:
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
Every time you will start same service it will start on unique port
It will register itself with eureka discovery service
Load Balancing will be done automatically since ribbon comes built in with Zuul
I've tried to add
spring:
main:
web-application-type: none
management:
server:
port: 8081
endpoints:
web:
exposure:
include: '*'
But with that none property tomcat server with actuator endpoint doesn't get started
Is there a way via configuration to blacklist specific ip addresses from registering as microservices with Spring Eureka cloud discovery? It seems that each time I restart my discovery service an unrecognized ip instance is registering as a microservice. From the attached image I would expect that only a single instance be present rather than the two shown.
Currently the application.yml file is configured as follows:
---
# This default profile is used when running a single instance completely standalone:
#spring:
# profiles: default
server:
port: 8010
eureka:
instance:
hostname: eurekahost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
security:
basic:
enabled: false
user:
name: user # login username
password: password
Although this is not my ideal solution since I prefer to do this via configuration, I found that I can de-register the service via Eureka's REST API.
I've set those parameters in my application.yml:
spring:
servlet:
multipart:
max-file-size: -1
max-request-size: -1
and when I run it from IDE it works fine. The problem starts when I try to run it along with spring cloud, netflix eureka, and zuul proxy. It behaves like there is no such paramteters. It always throws:
"Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.",
Shall I set it somewhere else?
EDIT:
My bootstrap.yml
spring:
profiles: docker
application:
name: test-service
sleuth:
sampler:
probability: 1
zipkin:
base-url: http://zipkin:9411/
cloud:
config:
discovery:
enabled: true
service-id: config-server
fail-fast: true
retry:
initial-interval: 2000
max-interval: 10000
multiplier: 2
max-attempts: 10
eureka:
instance:
hostname: test-service
prefer-ip-address: true
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://eureka-server:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
logging:
file: ./logs/log.log
Faced the same issue and found the solution, post it here still anyone needs help after 3years.
If your traffic flow through the Netflix Zuul edge service, you should update the below properties in both Zuul and your file upload application service.
for spring boot 2.x and above its
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1
According to section 3.2 of the Spring Cloud Consul manual:
An HTTP Check is created by default that Consul hits the /health
endpoint every 10 seconds.
However, the log of my application reveals that this health check is missing. The property http should have a valid url and interval should have 10s, both are null:
Registering service with consul:
NewService{id='test-service-local-8081', name='test-service', tags=[],
address='localhost', port=8081, enableTagOverride=null,
check=Check{script='null', interval='null', ttl='30s', http='null',
tcp='null', timeout='null', deregisterCriticalServiceAfter='null',
tlsSkipVerify=null, status='null'}, checks=null}
Also, when I make my health endpoint return "status: down", consul still reports that my service is fine.
How do I add the HTTP check to /health on registration of the Spring Boot service with Consul?
I am using the following properties:
management:
endpoints:
web:
base-path: /manage
spring:
application:
name: test-service
cloud:
consul:
host: consul
port: 8500
discovery:
healthCheckInterval: 10s
healthCheckPath: "${management.endpoints.web.base-path}/health"
heartbeat:
enabled: true
hostname: localhost
Edit: It turns out the heartbeat.enabled=true property removes the default HTTP check. When removing this property, we can see the HTTP check in the log:
Registering service with consul:
NewService{id='test-service-local-8081', name='test-service',
tags=[], address='erwins-mbp.home', port=8081, enableTagOverride=null,
check=Check{script='null', interval='1s', ttl='null',
http='http://mbp.home:8081/manage/health', tcp='null',
timeout='null', deregisterCriticalServiceAfter='null',
tlsSkipVerify=null, status='null'}, checks=null}
So, now, the question is, with heartbeat enabled, how to I register a HTTP check from Spring Boot to Consul?