允许网络内的 REST URL,并阻止外部流量

Allowing REST URL within network, and blocking outside traffic

假设我的 REST API URL 是

http://myshop.com/rest/api/product/1

我希望仅在公司网络内调用此 return 数据时,其他人不应返回任何结果。

以下是 can/cannot 可访问的用例

感谢观看。

我建议从请求中获取 IP 地址,然后通过允许的 IP 或子网掩码检查它。如果您使用的是 JAX-RS API,如何获取 IP 地址,您可以在此处找到:How to find out incoming RESTful request's IP using JAX-RS on Heroku?

另一种选择当然是通过防火墙或服务器设置阻止传入请求。