为 Secure Gateway 的 Bluemix 应用程序创建 IP table 规则

Creating IP table rules for a Bluemix app for Secure Gateway

Bluemix Doc 中有安全网关服务的新部分:Creating IP table rules for a Bluemix app

不幸的是我不知道我应该做什么。例如文本说要以这种形式进行 API 调用:PUT /v1/sgconfig/:<gateway_id>/destinations/:<endpoint_id>/ipTableRule 那永远行不通,它应该说 curl -k --request PUT https://sgmanager.ng.bluemix.net/v1/sgconfig/...

此外,在安全网关定义中,在 Advanced / Network Options 下,我是否需要检查 Restrict network access to cloud endpoint 的选项?

有人可以修改文本,更重要的是,请添加示例吗?

如果您想执行 IP Table 规则,那么是的,您需要选中 Restrict network access to cloud endpoint 框。那时你可以添加你想要强制执行的规则,例如:192.0.0.1 9000(单个 IP 和端口),192.0.0.1-192.0.0.5 5000:5005(IP 范围和端口范围),或其中的任意组合。

如果您使用 cURL 创建私人目的地,您可以使用如下命令:

curl "https://sgmanager.ng.bluemix.net/v1/sgconfig/<gateway_id>/destinations" \
-H "Authorization: Bearer <security_token>" \
-H "Content-type: application/json" \
-d '{"desc":"My Private Destination","ip":"1.1.1.1","port":8000,"private":true}' -k

创建私人目的地后,您可以使用以下命令添加 IP table 规则:

curl -X PUT "https://sgmanager.ng.bluemix.net/v1/sgconfig/<gateway_id>/destinations/<destination_id>/ipTableRule" \
-H "Authorization: Bearer <security_token>" \
-H "Content-type: application/json" \
-d '{"src":"192.0.0.1","spt":"9000"}' -k

curl -X PUT "https://sgmanager.ng.bluemix.net/v1/sgconfig/<gateway_id>/destinations/<destination_id>/ipTableRule" \
-H "Authorization: Bearer <security_token>" \
-H "Content-type: application/json" \
-d '{"src_range":"192.0.0.1-192.0.0.5","spt":"5000:5005"}' -k

请注意,此处的第一个命令使用 src 提供单个 IP,而第二个命令使用 src_range 提供一系列 IP。