Why am I getting 404 NOT FOUND when using zuul?

I’m using springboot, zuul and eureka.

When I try to reach a springboot endpoint through a zuul service, I get 404 NOT FOUND.

I run all the services with docker containers.

Do anyone of you know what might be wrong?

The springboot service with the resouces (which I’m trying to reach through zuul) is called ContentService.

The endpoint in the ContentService I’m trying to reach

@RestController
@RequestMapping("/content")
@RequiredArgsConstructor
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class CommunityController {


    private CommuntiyService communtiyService;

    @Autowired
    private ACLverifier acLverifier;


    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostMapping("/send_message/{message}")
    public void sendMessage(
            @PathVariable("message") String message
    ) {
        System.out.println("sent message: " + message);
        rabbitTemplate.convertAndSend("commentExchange", "commentRoutingKey", message);
    }

Post request Im sending:

http://localhost:8080/cont/content/send_message/hallo

Response – 404 NOT FOUND:

{
    "timestamp": "2024-06-26T08:20:29.052+00:00",
    "path": "/cont/content/send_message/hallo",
    "status": 404,
    "error": "Not Found",
    "requestId": "2355b902"
}

ContentService

application.properties:

spring.application.name=ContentService
server.port=8082

spring.data.mongodb.uri=mongodb://mongodb:27017/test

# Use the database with:
# docker exec -it mongodb bash
# mongosh
# show dbs
# use <collection>
# db.<entity>.find()

# JWT
security.jwt.secret-key=3cfa76ef14937c1c0ea519f8fc057a80fcd04a7420f8e8bcd0a7567c272e007b
# 1h in millisecond
security.jwt.expiration-time=3600000

# rabbitmq
spring.rabbitmq.host=rabbitmq
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

# Eureka
# eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://eureka:8761/eureka}

# Actuator
management.endpoints.web.exposure.include=*

Application:

@EnableDiscoveryClient
@EnableFeignClients
@SpringBootApplication
public class ContentServiceApplication {

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

}

Eureka

application.properties:

spring.application.name=Eruka
server.port=8761

eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone=http://eureka:8761/eureka
eureka.renewalPercentThreshold=0.85

Application:

@EnableEurekaServer
@SpringBootApplication
public class ErukaApplication {

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

}

Gateway/Zuul

application.properties:

spring.application.name=Gateway
server.port=8080

spring.docker.compose.enabled=false
spring.main.web-application-type=reactive

spring.jpa.hibernate.ddl-auto=none


# Eureka
# eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://eureka:8761/eureka}


# Actuator
management.endpoints.web.exposure.include=*
management.port=8080

# ===================================
# Zuul

# Content service
zuul.routes.content-service.serviceId=content-service
zuul.routes.content-service.path=/cont/**
zuul.routes.content-service.stripPrefix=true

Application:

@EnableDiscoveryClient
@EnableZuulProxy
@SpringBootApplication
public class GatewayApplication {

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

I run all the services with a docker-compose file:

version: '3.8'

services:

  # ============= GATEWAY ===============
  gateway:
    build:
      context: .
      dockerfile: API_GATEWAY/DockerfileGateway
    container_name: Gateway
    ports:
      - "8080:8080"
    networks:
      - ms_architecture
  # ===================================

  # ============= EUREKA ===============
  eureka:
    build:
      context: .
      dockerfile: API_GATEWAY/DockerfileEruka
    container_name: Eureka
    ports:
      - "8761:8761"
    networks:
      - ms_architecture
  # ===================================

    # ============= CONTENT SERVICE ===============

  mongodb:
    image: mongo:latest
    container_name: mongodb
    ports:
      - 27017:27017
    networks:
      - ms_architecture

  content_service:
    build:
      context: .
      dockerfile: MicroServices/Content/ContentServiceDockerfile
    depends_on:
      - mongodb
    ports:
      - "8082:8082"
    environment:
      SPRING_DATA_MONGODB_URI: mongodb://mongodb:27017/test
      RABBITMQ_HOST: rabbitmq
      RABBITMQ_PORT: 5672
    networks:
      - ms_architecture
  # ===================================


  # ============= RABBITMQ ===============
  rabbitmq:
    image: rabbitmq:management
    container_name: rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    networks:
      - ms_architecture
    healthcheck:
      test: ["CMD", "rabbitmqctl", "status"]
      interval: 30s
      timeout: 10s
      retries: 3

  # ===================================

networks:
  ms_architecture:
    driver: bridge

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật