• k8s部署gateway、nacos 、app通过网关访问app出现404


    1. server:
    2. port: 9996
    3. spring:
    4. security:
    5. user:
    6. name: admin
    7. password: 123456
    8. cloud:
    9. gateway:
    10. enabled: true
    11. loadbalancer:
    12. use404: true
    13. discovery:
    14. locator:
    15. enabled: true
    16. lower_case_service_id: true
    17. routes:
    18. - id: baidu
    19. uri: https://www.baidu.com
    20. predicates:
    21. - Path=/baidu
    22. filters:
    23. - StripPrefix=1
    24. - id: path
    25. uri: http://127.0.0.1:8090
    26. predicates:
    27. - Path=/demo
    28. filters:
    29. - StripPrefix=1
    30. - id: nacos
    31. uri: http://10.10.10.99:30018/nacos/#/serviceManagement?dataId=&group=&appName=&namespace=&pageSize=&pageNo=
    32. predicates:
    33. - Path=/nacos
    34. filters:
    35. - StripPrefix=1
    36. #设置的id是dubbo-starter-reference
    37. - id: reference
    38. #网关不设置上下问,服务存在上下问情况
    39. #找不到lb实例,这种写法管用的 http://dubbo-starter-reference:9997,-Path设置为 - Path=/dubbo-reference/**
    40. uri: lb://dubbo-starter-reference
    41. predicates:
    42. - Path=/reference/**
    43. filters:
    44. ##由于微服务dubbo-starter-reference中设置了server.servlet.context-path=/dubbo-starter-reference,要重写路径才能正常路由到该微服务
    45. - RewritePath=/reference/?(?<segment>.*), /dubbo-starter-reference/$\{segment}
    46. management:
    47. endpoint:
    48. gateway:
    49. #默认是true
    50. enabled: true
    51. endpoints:
    52. web:
    53. exposure:
    54. #一直存在的
    55. include: "*"
    56. hystrix:
    57. command:
    58. default:
    59. execution:
    60. isolation:
    61. strategy: SEMAPHORE
    62. thread:
    63. timeoutInMilliseconds: 3000
    64. shareSecurityContext: true

    上面是网关的简单配置,使用http://dubbo-starter-reference:9997可以访问成功

    进入gateway的pod容器,连接dubbo-starter-reference实例正常,

    将uri: lb://dubbo-starter-reference,访问接口出现404的错误。

    描述:pom.xml描述,配置了actuator,并且application.yaml中设置

     

     

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4. <modelVersion>4.0.0</modelVersion>
    5. <parent>
    6. <groupId>org.springframework.boot</groupId>
    7. <artifactId>spring-boot-starter-parent</artifactId>
    8. <version>2.6.3</version>
    9. <relativePath/>
    10. </parent>
    11. <artifactId>gateway-gateway</artifactId>
    12. <name>gateway-gateway</name>
    13. <version>0.0.1-SNAPSHOT</version>
    14. <properties>
    15. <swagger.version>2.9.2</swagger.version>
    16. </properties>
    17. <dependencies>
    18. <dependency>
    19. <groupId>cn.hutool</groupId>
    20. <artifactId>hutool-all</artifactId>
    21. <version>5.8.6</version>
    22. </dependency>
    23. <dependency>
    24. <groupId>com.alibaba.cloud</groupId>
    25. <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    26. <version>2021.0.1.0</version>
    27. </dependency>
    28. <dependency>
    29. <groupId>com.alibaba.cloud</groupId>
    30. <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    31. <version>2021.0.1.0</version>
    32. </dependency>
    33. &
  • 相关阅读:
    如何使用高压放大器驱动高容性负载
    POJ 2991 Crane 线段树
    2021 中国系统java面试笔试题(含面试题解析)
    【java学习—七】多态性(34)
    C++人事管理系统
    Android基础第四天 | 字节跳动第四届青训营笔记
    Mysql—六大日志
    Android aar 打包事项
    【JavaEE&Spring】Spring Web MVC⼊⻔
    Taurus.MVC 微服务框架 入门开发教程:项目部署:3、微服务应用程序版本升级:全站升级和局部模块升级。
  • 原文地址:https://blog.csdn.net/TT1024167802/article/details/126810622