[英]Zuul not forwarding requests to other micro-services
I am using spring boot micro-services.我正在使用 Spring Boot 微服务。 I have configured eureka, zuul proxy and another microservice(account).
我已经配置了 eureka、zuul 代理和另一个微服务(帐户)。 If I am calling from account directly it is working fine.
如果我直接从帐户打电话,它工作正常。 account and zuul server both showing on eureka.
帐户和 zuul 服务器都显示在尤里卡上。
When I try to hit using zuul proxy it is getting status code 200OK
but not getting any result当我尝试使用 zuul 代理点击时,它得到状态代码
200OK
但没有得到任何结果
Below is my configuration for zuul以下是我对 zuul 的配置
server:
port: 8076
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8078/eureka/
instance:
hostname: localhost
health-check-url-path: /actuator/health
status-page-url-path: /actuator/info
logging:
level:
com.netflix.discovery: 'ON'
org.springframework.cloud: DEBUG
zuul:
ignoredServices: '*'
routes:
account:
serviceId: ACCOUNT
url: http://192.168.0.62:8081/
stripPrefix: false
predicate:
- Path=/accounts/**
debug:
requests: true
management:
security:
enabled: false
endpoints:
web:
exposure:
include: '*'
Console log so far到目前为止的控制台日志
route matched=ZuulRoute{id='account', path='/account/**', serviceId='ACCOUNT', url=' http://192.168.0.62:8081/ ', stripPrefix=false, retryable=null, sensitiveHeaders=[], customSensitiveHeaders=false, } --------------------------- Mapped to org.springframework.cloud.netflix.zuul.web.ZuulController@7bb67520
路由匹配=ZuulRoute{id='account', path='/account/**', serviceId='ACCOUNT', url=' http://192.168.0.62:8081/ ', stripPrefix=false, retryable=null, sensitiveHeaders=[], customSensitiveHeaders=false, } --------------------------- 映射到 org.springframework.cloud.netflix.zuul.web .ZuulController@7bb67520
"zuul.ignoredServices": {
"value": "*"
},
"zuul.routes.account.serviceId": {
"value": "ACCOUNT"
},
"zuul.routes.account.url": {
"value": "http://192.168.0.62:8081/"
},
"zuul.routes.account.stripPrefix": {
"value": false
},
"zuul.routes.account.predicate[0]": {
"value": "Path=/accounts/**"
},
"zuul.debug.requests": {
"value": true
},
"management.security.enabled": {
"value": false
},
"management.endpoints.web.exposure.include": {
"value": "*"
}
I am unable to get anything from here if something is mising, Kindly check and do let me know.如果有什么遗漏,我无法从这里得到任何东西,请检查并告诉我。 any help will be useful
任何帮助都会有用
thanks.谢谢。
If needed more info let me know.如果需要更多信息,请告诉我。
As I can see, you set up Eureka but you're not using it correctly.正如我所看到的,您设置了 Eureka,但没有正确使用它。 First in zuul yaml you have
首先在 zuul yaml 你有
eureka:
client:
registerWithEureka: true
you don't need to register your zuul application with eureka, because you are accessing zuul gateway directly, no one service will try to locate and reach your gateway.您不需要在 eureka 注册您的 zuul 应用程序,因为您是直接访问 zuul 网关,没有任何服务会尝试定位并到达您的网关。
Then然后
account:
serviceId: ACCOUNT
url: http://192.168.0.62:8081/
stripPrefix: false
predicate:
- Path=/accounts/**
if you have service discovery you don't need url
property and predicate: - Path
, try:如果您有服务发现,则不需要
url
属性和predicate: - Path
,请尝试:
account:
serviceId: <YOUR_ACCOUNT_SERVICE_ID>
stripPrefix: false
path: /account/**
by default serviceId is:默认情况下 serviceId 是:
spring:
application:
name: <YOUR_ACCOUNT_SERVICE_ID>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.