本地环境中将“grpc到REST连接”的Envoy配置
创始人
2024-11-29 16:30:24
0

要将gRPC转换为REST连接的Envoy配置,您需要使用Envoy的HTTP/1.1转发器来实现。以下是一个简单的Envoy配置示例,将gRPC请求转发为REST请求:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8080
      filter_chains:
        - filters:
            - name: envoy.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
                stat_prefix: ingress_http
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: local_service
                      domains: ["*"]
                      routes:
                        - match:
                            prefix: "/"
                          route:
                            cluster: grpc_cluster
                            max_grpc_timeout: 0s
                http_filters:
                  - name: envoy.grpc_json_transcoder
                    typed_config:
                      "@type": type.googleapis.com/envoy.config.filter.http.grpc_json_transcoder.v2.GrpcJsonTranscoder
                      proto_descriptor: "/path/to/your/proto/descriptor/file"
                      services: ["YourService"]
                      print_options:
                        add_whitespace: true
                        always_print_primitive_fields: true
                        always_print_enums_as_ints: false
                codec_type: auto
  clusters:
    - name: grpc_cluster
      connect_timeout: 0.25s
      type: strict_dns
      lb_policy: round_robin
      http2_protocol_options: {}
      hosts:
        - socket_address:
            address: localhost
            port_value: 50051

这个配置中,listener部分定义了Envoy监听的地址和端口。filter_chains部分定义了请求过滤器链,使用envoy.http_connection_manager进行处理。http_filters部分指定了要使用的gRPC到REST转码器,proto_descriptor字段需要指定您的proto文件描述符的路径,services字段需要指定要转码的gRPC服务名称。

clusters部分定义了要连接的gRPC服务的主机和端口。

请注意,您需要根据您的实际情况调整配置中的地址、端口和路径等参数。

希望这可以帮助到您!

相关内容

热门资讯

线上(wepoke真的)原来是... 线上(wepoke真的)原来是真的有挂!其实真的有挂(2022已更新)(哔哩哔哩);亲,其实确实真的...
两教程(Wepoke程序)软件... 两教程(Wepoke程序)软件透明挂辅助工具(软件透明挂)透视辅助(2024已更新)(哔哩哔哩);致...
软件(wepoke透明)原来是... 软件(wepoke透明)原来是真的有挂!其实真的有挂(2020已更新)(哔哩哔哩)是一款可以让一直输...
一模拟器(德扑工具)外挂辅助工... 一模拟器(德扑工具)外挂辅助工具(透视)透视辅助(2025已更新)(哔哩哔哩);亲真的是有正版授权,...
系统(aapoker讲解)竟然... 系统(aapoker讲解)竟然真的有挂!其实真的有挂(2021已更新)(哔哩哔哩);aapoker讲...
6系统(aapoker下载)外... 6系统(aapoker下载)外挂辅助工具(辅助挂)透视辅助(2023已更新)(哔哩哔哩)aapoke...
智能(德扑之星刷数据)果真真的... 智能(德扑之星刷数据)果真真的有挂!原来真的有挂(2025已更新)(哔哩哔哩);《WPK辅助透视》‌...
1机器人(德州nzt软件)软件... 1机器人(德州nzt软件)软件透明挂辅助软件(透视)透视辅助(2022已更新)(哔哩哔哩);人气非常...
ai代打(德扑之星决策)确实是... ai代打(德扑之星决策)确实是真的有挂!原来真的有挂(2020已更新)(哔哩哔哩);科技详细教程小薇...
第8透明(wepoke数据)外... 第8透明(wepoke数据)外挂透明挂辅助神器(辅助挂)透视辅助(2023已更新)(哔哩哔哩);原来...