在envoyproxy中配置公共访问Web API的步骤如下:
routes:
- match:
prefix: "/api"
methods: ["GET"]
route:
cluster: api_cluster
clusters:
- name: api_cluster
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: api_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: <目标服务器的IP地址>
port_value: <目标服务器的端口号>
listeners:
- name: public_listener
address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
route_config:
name: public_route
virtual_hosts:
- name: public_host
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: api_cluster
timeout: 0.5s
通过以上步骤,你就可以在envoyproxy中配置公共访问Web API了。请根据实际情况替换配置文件中的目标服务器地址和端口号。推荐使用腾讯云的API网关产品来管理和保护你的Web API,具体可参考腾讯云API网关产品介绍:https://cloud.tencent.com/product/apigateway。
领取专属 10元无门槛券
手把手带您无忧上云