One of the important functions of gateway is routing and forwarding. We often encounter the problem of forwarding failure
for example, the front-end configuration is as follows:
// api interface request address
window.SITE_CONFIG['baseUrl'] = 'http://localhost:90/api';
The application.yml configuration of gateway is as follows:
server:
port: 90
spring:
application:
name: threat-gateway
cloud:
gateway:
routes:
# threat-ip microservice routing and forwarding
- id: ip_route
# The forwarding address of the matching route
uri: lb://threat-ip
predicates:
- Path=/api/cyber_threat_ip/**
filters:
- RewritePath=/api/(?<segment>.*),/$\{segment}
The reason for the error may be that the registry (such as Nacos) is not enabled, resulting in the unrecognized name of the microservice
it is revised as follows:
# Match the forwarding address of the route (8082 is the threat-ip microservice port)
uri: localhost:8082
As a result, an error was reported because http://, should be added in front of the URI, as follows:
# Match the forwarding address of the route (8082 is the threat-ip microservice port)
uri: http://localhost:8082
As a result, you can visit it
of course, the rewritepath path rewriting error in filters may also cause access error. Other reasons will be added later.
Read More:
- spring cloud 2020 gateway Error 503 [How to Solve]
- Zuul Gateway Failed to Import Dependency [How to Solve]
- [Solved] nacos Error: com.alibaba.nacos.api.exception.NacosException: failed to req API:/nacos/v1/ns/instance
- Gateway Error: allowedOrigins cannot contain the special value “*“
- [Solved] Redis Error: Error condition on socket for SYNC: No route to host
- springcloud alibaba Integrating nacos reports errors: create config service error!properties=NacosConfigPropertie
- Spring Cloud Hoxton.SR9 gateway and reactor-netty 0.9.0.RELEASE is Incompatible [How to Solve]
- [Solved] Nacos1.3.2 Startup Error: Unable to start embedded Tomcat
- Nacos boot error, unable to find Java_HOME [How to Solve]
- [Solved] Project Startup Error: Redis health check failed:Unable to connect to localhost6379
- [Solved] Project Startup Error: Redis health check failed: Unable to connect to localhost6379
- [Solved] SpringBoot Startup Error: Unable to start LiveReload server
- Springcloud builds a gateway and starts Error [Solved]
- [Solved] nacos Startup Error: Unable to start embedded Tomcat
- [Solved] Unable to connect to a as user root com.jcraft.jsch.JSchException: Auth failUnable to connect
- How to Fix log4j2 warning: warn unable to identify org.fusesource.jansi.WindowsAnsiOutputStream
- [Solved] Springboot Project Startup Error: Unable to Identify bootstrap.yml Configuration
- [Solved] com.alibaba.druid.filter.FilterManager : load filter error, filter not found : sl4j
- [Solved] com.alibaba.fastjson.JSONException: syntax error, pos 1, json
- [Solved] Failed toString() invocation on an object com.alibaba.fastjson.JSONException: write javaBean error