简体   繁体   English

如何在一个 Spring Boot 应用程序中的不同端口上运行 api-gateway(Netflix Zuul) 和 Eureka Server

[英]How to run api-gateway(Netflix Zuul) and Eureka Server on different port in one Spring Boot application

I have a Spring Boot application which is EurekaServer as well as ZuulServer .我有一个Spring Boot应用程序,它是EurekaServerZuulServer My questions are:我的问题是:

  • Is it possible to run both servers on different ports?是否可以在不同端口上运行两台服务器?
  • If possible then, what should be the application configuration?如果可能的话,应用程序配置应该是什么?

I have attached the configuration which I tried, but it's not giving me the desired output.我附上了我尝试过的配置,但它没有给我想要的输出。

@SpringBootApplication
@EnableZuulProxy
@EnableEurekaServer
public class AppApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(AppApiGatewayApplication.class, args);
    }

}

spring:
  application:
    name: gateway

server:
  port: 8001

eureka:
  instance:
   hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:9090/eureka/       

You can try like below您可以尝试如下

server:
  port: ${appPort:8880}
  additionalPorts: 8882,8883

# Spring MVC actuator endpoints available via /admin/info, /admin/health, ...
server.servlet-path: /
management:
  context-path: /admin
  port: 8881 

The best way to design microservice is to have separate EurekaServer and register your ZuulServer to Eureka.设计微服务的最佳方式是拥有单独的 EurekaServer,并将您的 ZuulServer 注册到 Eureka。 Please refer below link请参考以下链接

https://tech.asimio.net/2016/12/15/Configuring-Tomcat-to-Listen-on-Multiple-ports-using-Spring-Boot.html https://tech.asimio.net/2016/12/15/Configuring-Tomcat-to-Listen-on-Multiple-ports-using-Spring-Boot.html

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

相关问题 Spring Boot2 和 Netflix Zuul - Spring Boot2 and Netflix Zuul Netflix Eureka Server 未使用 JDK 11 作为 Spring-Boot 应用程序启动。 但同样是在 JDK1.8 上运行 - Netflix Eureka Server Not starting as Spring-Boot Application with JDK 11 . But same is running with JDK1.8 Spring 引导 2.4.2 网关 API 与 Zuul - Spring Boot 2.4.2 Gateway API with Zuul 微服务架构,Spring Cloud Config Server、Zuul Gateway Server、Eureka Server是否应该作为资源进行保护? - Micro-Service Architecture, Should the Spring Cloud Config Server, Zuul Gateway Server and Eureka Server be protected as Resources? Spring 引导应用程序在 Eureka 服务器中显示为未知 - Spring Boot Application shown as UNKNOWN in Eureka server Spring Boot Zuul API Gateway 返回 404 响应 - Spring Boot Zuul API Gateway returning a 404 response 如何使用Netflix / Eureka Service的发现信息在Netflix / Zuul和Netflix / Ribbon中启用自动路由? - How to enable automatic routing in Netflix/Zuul and Netflix/Ribbon with discovery information from Netflix/Eureka Service? 如何在不同主机上使用eureka-server注册eureka-clients。 春季启动 - How to register eureka-clients with eureka-server on different hosts. Spring-boot Zuul Server运行应用程序 - Zuul Server run application Dockerized Zuul Gateway 无法连接到 Dockerized Eureka Server - Dockerized Zuul Gateway failing to connect to dockerized Eureka Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM