提问者:小点点

Heroku上的部署问题:zuul eureka微服务


感谢您花时间阅读我的帖子。

我的问题是这样的。我在Heroku上部署了2个微服务(auth-service和image-service),以及一个服务器Eureka和一个网关Zuul。

在当地,所有这些都有效。

但是,当部署时,相同的调用会给我404错误:例如:zuul部署在本地的端口8762上,所以http://localhost:8762/images/user/create工作,它指向图像服务的http://localhost:8200/user/create。部署后,https://croquis-time-image.herokuapp.com/user/create工作,但https://croquis-time-zuul.herokuapp.com/images/user/create抛出404错误。然而,在eureka上,我的所有服务都注册了,所以问题不是来自那里。我想也许zuul没有设法从Eureka获得所有服务,但我不知道如何检查。

更多信息:zuul的application. yml部署:

server:
  port: 8762

eureka:
  client:
    serviceUrl:
      defaultZone: https://croquis-time-eureka.herokuapp.com/eureka/
  instance:
    hostName: croquis-time-eureka.herokuapp.com

zuul:
  #Service will be mapped under the /api URI
  prefix: /api
#  Uncomment to disable auto-registering all services read from Eureka
 # ignoredServices: '*'
  routes:
    image-service:
      path: /images/**
      serviceId: image-service
    auth-service:
      path: /auth/**
      serviceId: auth-service
      stripPrefix: false
      sensitiveHeaders: Cookie,Set-Cookie

spring:
  application:
    name: zuul-server

security:
  jwt:
    uri: /auth/**
    prefix: Bearer
    expiration: 86400
    header: Authorization
    secret: *****************

部署的eureka的application. yml

server:
  port: 8761

eureka:
  instance:
    hostname: croquis-time-eureka.herokuapp.com
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: https://croquis-time-eureka.herokuapp.com/eureka/
spring:
   application:
       name: eureka-server

我尝试调用的图像服务:

server:
  port: 8200

eureka:
  client:
    serviceUrl:
      defaultZone: https://croquis-time-eureka.herokuapp.com/eureka/
  instance:
    hostName: croquis-time-eureka.herokuapp.com
spring:
  application:
    name: image-service
  jpa:
    showSql: true
    hibernate:
      ddlAuto: update
  datasource:
    url: jdbc:mysql://***********:3306/croquis-time
    username: ******************
    password: ****************

我已经尝试从zuul中删除和添加“忽略的服务”,看看这是否是问题所在,但这并没有改变任何事情。如果您需要更多信息,我非常愿意编辑我的问题,我不确定问题的起源在哪里,所以我有点不知所措,不知道该添加什么。

谢谢!


共1个答案

匿名用户

您在zuul服务器中的. yml配置有问题您的zuul服务器的.yml必须是:

instance:
    hostName: croquis-time-zuul.herokuapp.com

并且您的. yml图像必须是:

instance:
    hostName: croquis-time-image.herokuapp.com

因为instance. hostname是作为eureka客户端的应用程序的主机。如果你需要更多信息,请访问:https://blog.heroku.com/managing_your_microservices_on_heroku_with_netflix_s_eureka