简体   繁体   English

Zuul 不向其他微服务转发请求

[英]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 的配置

Zuul.yml Zuul.yml

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

log of actuator/env执行器/环境日志

"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>

check my answer from here这里检查我的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 内部微服务通信是否应该通过zuul网关? - Should internal micro-services communication goes through zuul gateway? 微服务项目中的Maven可传递依赖项 - Maven transitive dependencies in micro-services project 在以下情况下如何设计微服务:- - How to design micro-services in the below scenario :- App Engine中微服务的更好性能 - Better performance for Micro-services in App Engine springcloud多模块项目的服务模块如何调用其他微服务 - How the service module of springcloud multi-module project calls other micro-services 在典型的微服务体系结构中,如何在微服务的单独的RDBMS数据库中链接相关数据? - How to link the related data in the separate RDBMS databases of the micro-services in a typical micro-services architecture? Java Spring-boot 微服务异常处理 - Java Spring-boot micro-services Exception handling 减少微服务架构中假装调用的使用 - Reduce the use of feign calls in micro-services architecture 多个pods/微服务更新/插入同一条记录 - Multiple pods/micro-services update/insert the same record 授权:动态组,基于权限的内容列表,基于微服务的架构? - Authorization with: dynamic groups, permission based content lists, micro-services based architecture?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM