• asp.net docker-compose添加网关和网关配置


    打开docker-compose.yml

    添加

    1. killsb-social-apigw:
    2. image: ${REGISTRY:-killsbdapr}/killsb-social-apigw:${TAG:-latest}
    3. build:
    4. context: .
    5. dockerfile: src/ApiGateways/SocialEnvoy/Dockerfile

    在路径src\ApiGateways\SocialEnvoy

    添加envoy.yaml

    1. admin:
    2. access_log_path: "/dev/null"
    3. address:
    4. socket_address:
    5. address: 0.0.0.0
    6. port_value: 8001
    7. static_resources:
    8. listeners:
    9. - address:
    10. socket_address:
    11. address: 0.0.0.0
    12. port_value: 80
    13. filter_chains:
    14. - filters:
    15. - name: envoy.http_connection_manager
    16. config:
    17. codec_type: auto
    18. stat_prefix: ingress_http
    19. route_config:
    20. name: eshop_backend_route
    21. virtual_hosts:
    22. - name: eshop_backend
    23. domains:
    24. - "*"
    25. cors:
    26. allow_origin_string_match:
    27. - safe_regex:
    28. google_re2: {}
    29. regex: \*
    30. allow_methods: "GET, POST, PUT"
    31. allow_headers: "authorization, content-type, x-requestid, x-requested-with, x-signalr-user-agent"
    32. allow_credentials: true
    33. routes:
    34. - name: "pics"
    35. match:
    36. prefix: "/pics/"
    37. route:
    38. auto_host_rewrite: true
    39. prefix_rewrite: "/"
    40. cluster: image-api
    41. timeout: 300s
    42. - name: "c-short"
    43. match:
    44. prefix: "/b/"
    45. route:
    46. auto_host_rewrite: true
    47. prefix_rewrite: "/"
    48. cluster: blog-api
    49. timeout: 300s
    50. - name: "c-long"
    51. match:
    52. prefix: "/blog-api/"
    53. route:
    54. auto_host_rewrite: true
    55. prefix_rewrite: "/"
    56. cluster: blog-api
    57. timeout: 300s
    58. - name: "f-short"
    59. match:
    60. prefix: "/f/"
    61. route:
    62. auto_host_rewrite: true
    63. prefix_rewrite: "/"
    64. cluster: forum-api
    65. timeout: 300s
    66. - name: "f-long"
    67. match:
    68. prefix: "/forum-api/"
    69. route:
    70. auto_host_rewrite: true
    71. prefix_rewrite: "/"
    72. cluster: forum-api
    73. timeout: 300s
    74. - name: "f-short"
    75. match:
    76. prefix: "/a/"
    77. route:
    78. auto_host_rewrite: true
    79. prefix_rewrite: "/"
    80. cluster: account-api
    81. timeout: 300s
    82. - name: "f-long"
    83. match:
    84. prefix: "/account-api/"
    85. route:
    86. auto_host_rewrite: true
    87. prefix_rewrite: "/"
    88. cluster: account-api
    89. timeout: 300s
    90. http_filters:
    91. - name: envoy.cors
    92. - name: envoy.router
    93. access_log:
    94. - name: envoy.file_access_log
    95. filter:
    96. not_health_check_filter: {}
    97. config:
    98. json_format:
    99. time: "%START_TIME%"
    100. protocol: "%PROTOCOL%"
    101. duration: "%DURATION%"
    102. request_method: "%REQ(:METHOD)%"
    103. request_host: "%REQ(HOST)%"
    104. path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
    105. response_flags: "%RESPONSE_FLAGS%"
    106. route_name: "%ROUTE_NAME%"
    107. upstream_host: "%UPSTREAM_HOST%"
    108. upstream_cluster: "%UPSTREAM_CLUSTER%"
    109. upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
    110. path: "/tmp/access.log"
    111. clusters:
    112. - name: dapr
    113. connect_timeout: 0.25s
    114. type: strict_dns
    115. lb_policy: round_robin
    116. hosts:
    117. - socket_address:
    118. address: 127.0.0.1
    119. port_value: 3500
    120. - name: image-api
    121. connect_timeout: 0.25s
    122. type: strict_dns
    123. lb_policy: round_robin
    124. hosts:
    125. - socket_address:
    126. address: ${ENVOY_SOCIAL_IMAGE_API}
    127. port_value: 80
    128. - name: blog-api
    129. connect_timeout: 0.25s
    130. type: strict_dns
    131. lb_policy: round_robin
    132. hosts:
    133. - socket_address:
    134. address: ${ENVOY_SOCIAL_BLOG_API}
    135. port_value: 80
    136. - name: forum-api
    137. connect_timeout: 0.25s
    138. type: strict_dns
    139. lb_policy: round_robin
    140. hosts:
    141. - socket_address:
    142. address: ${ENVOY_SOCIAL_FORUM_API}
    143. port_value: 80
    144. - name: account-api
    145. connect_timeout: 0.25s
    146. type: strict_dns
    147. lb_policy: round_robin
    148. hosts:
    149. - socket_address:
    150. address: ${ACCOUNT_API}
    151. port_value: 80

    添加Dockerfile

    1. FROM envoyproxy/envoy:v1.14.2
    2. COPY src/ApiGateways/SocialEnvoy/envoy.yaml /tmpl/envoy.yaml.tmpl
    3. COPY src/ApiGateways/SocialEnvoy/docker-entrypoint.sh /
    4. RUN chmod 500 /docker-entrypoint.sh
    5. RUN apt-get update && \
    6. apt-get install gettext -y
    7. ENTRYPOINT ["/docker-entrypoint.sh"]

    添加docker-entrypoint.sh

    1. #!/bin/sh
    2. set -e
    3. echo "Generating envoy.yaml config file..."
    4. cat /tmpl/envoy.yaml.tmpl | envsubst \$ENVOY_SOCIAL_BLOG_API,\$ENVOY_SOCIAL_FORUM_API,\$ENVOY_SOCIAL_IMAGE_API,\$ACCOUNT_API > /etc/envoy.yaml
    5. echo "Starting Envoy..."
    6. /usr/local/bin/envoy -c /etc/envoy.yaml

    运行vs2022

  • 相关阅读:
    Java集合框架详解(一)Collection接口、List接口、ArrayList类、Vector类
    Nuxt.js 应用中的 kit:compatibility 事件钩子详解
    新库上线 | CnOpenData采矿业工商注册企业基本信息数据
    万向区块链肖风:产业元宇宙的“液化现象”
    MyBatis-Plus快速开发
    微信H5公众号获取openid爬坑记
    如何使用Node编写开发小工具
    快速提升独立站转化率
    1600*C. Good Subarrays(找规律&&前缀和)
    MySQL性能优化之buffer pool配置优化
  • 原文地址:https://blog.csdn.net/loongsking/article/details/134281338