Consul Integration spring cloud gateway cannot access other services

problem description

use consul as the registry
spring cloud gateway as the gateway

clipboard.png
gateway user

user

spring cloud gateway 404

clipboard.png

the environmental background of the problems and what methods you have tried

related codes



spring:
  profiles:
    active: dev
  application:
    name: angelcloud-gateway
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
-sharp      filter:
-sharp        remove-non-proxy-headers:
-sharp          headers:
-sharp          - dummy
      routes:
      - id: baidu
        -sharp /infohttplb
        uri: http://www.baidu.com/
         -sharp ,/userapi/**,
        predicates:
        - Path=/baidu/**
      -sharp - id: apiuser
        -sharp /infohttplb
        -sharp uri: lb://ANGELCLOUD-PROVIDER-USER
         -sharp ,/userapi/**,
        -sharp predicates:
        -sharp - Path=/ANGELCLOUD-PROVIDER-USER/**
    consul:
      host: localhost
      port: 8500
      healthCheckInterval: 15s

server:
  port: 8080

-sharp eureka:
-sharp  client:
-sharp    service-url:
-sharp      defaultZone: http://localhost:8761/eureka/

server:
  port: 8030

spring:
  profiles:
    active: dev
  application:
    -sharp name: @pom.artifactId@
    name: angelcloud-provider-user
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://127.0.0.1:3306/angelcloud_master?characterEncoding=utf-8&useSSL=false
  cloud:
    consul:
      host: localhost
      port: 8500
      healthCheckInterval: 15s
mybatis-plus:
  typeAliasesPackage: com.angel.provider.model.domain
  mapper-locations: classpath:mapper/*.xml,classpath*:sdk/mapper/*.xml
  configuration:
    -sharp 
    map-underscore-to-camel-case: true
mapper:
  mappers: com.angel.provider.mapper.*
  not-empty: false
  identity: MYSQL

-sharp pagehelper:
-sharp  helperDialect: mysql
-sharp  reasonable: true
-sharp  support-methods-arguments: true
-sharp  params: count=countSql


-sharp eureka:
-sharp  client:
-sharp    service-url:
-sharp      defaultZone: http://localhost:8761/eureka/

package com.angel.provider.web.frontend;


import com.angel.provider.model.domain.SysUser;
import com.angel.provider.service.ISysUserService;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 

* () *

* * @author aa * @since 2018-07-30 */ @RestController @RequestMapping("/sysUser") public class SysUserController { @Resource private ISysUserService iSysUserService; @GetMapping(value = "selectall") public String selectAll () { Page<SysUser> page =new Page<SysUser>(0, 10); Page<SysUser> sysUserPage = iSysUserService.selectPage(page); List<SysUser> records = sysUserPage.getRecords(); return records.toString(); } }

what result do you expect? What is the error message actually seen?

the solution is reported to 404 via gateway

Dec.09,2021

I can already access it, because if you have this dependency spring-boot-starter-actuator your consul configuration healthCheckPath cannot be configured as healthCheckPath: ${management.context-path} / health , you should use healthCheckPath: / actuator/health . From the consul ui page, personal guess is that you have added spring-boot-starter-actuator and configured healthCheckPath and then consul will call the address query service. But there is something wrong with the address that checks for health, so it is determined that the service cannot be obtained by gateway. (just personal opinion, please point out any mistakes)


the same question, do I write this or report 404


solved the attached apigatway configuration

spring:
  profiles:
    active: dev
  application:
    name: angelcloud-gateway
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
      routes:
        -sharp 
      - id: angelcloud-provider-user
        -sharp /infohttplb
        uri: lb://angelcloud-provider-user
         -sharp ,/userapi/**,
        predicates:
        - Path= /userapi/**
        filters:
        - StripPrefix= 1
        -sharp - RewritePath=/userapi/(?.*), /${segment}
      -sharp - id: apiuser
        -sharp /infohttplb
        -sharp uri: lb://ANGELCLOUD-PROVIDER-USER
         -sharp ,/userapi/**,
        -sharp predicates:
        -sharp - Path=/ANGELCLOUD-PROVIDER-USER/**

        -sharp 
      - id: angelcloud-provider-blog
        uri: lb://angelcloud-provider-blog
        predicates:
        - Path= /blogapi/**
        filters:
        - StripPrefix= 1
    consul:
      host: localhost
      port: 8500
      healthCheckInterval: 15s

server:
  port: 8082
  
  

lb://$ after uri {name of registration service}
predicates:

 - Path  
    /testapi/**   http://localhost:8082/testapi/ (gateway)     
   

filters: Filter rules

< H1 > add StripPrefix=1, remove testapi, and keep only * * part < / H1 >

can't services and routes be discovered automatically? for the last new service, it's too troublesome to change the gateway configuration again.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7ac1fc-7b68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7ac1fc-7b68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?