简体   繁体   English

掩盖API端点的网关

[英]Gateway to mask an API end point

That is the purpose, I have details about a commercial API and a white label on it. 那就是目的,我有关于商业API的详细信息以及上面的白色标签。

After by it, I want to resell it to the user of my website. 之后,我想将其转售给我的网站用户。

What is the best way to make redirection of an API to another with same request, parameters, credentials and response back. 将API重定向到具有相同请求,参数,凭据和响应的另一个API的最佳方法是什么。

Is there online service to do it ? 有在线服务吗? Or a technical example using Java spring or php ? 还是使用Java spring或php的技术示例?

EXAMPLE :

 1. POST, to http://www.commercialapi.com/product/save
{'name': 'customerName', 'nick': 'customerNick'}

 2. DELETE, to http://www.commercialapi.com/product/delete
{'id': 'customerId'}

transform to : 

 1. POST, to http://www.myapi.com/product/save
{'name': 'customerName', 'nick': 'customerNick'}

 2. DELETE, to http://www.myapi.com/product/delete
{'id': 'customerId'}

Thanks in advance. 提前致谢。

I think Nginx is good solution for this task. 我认为Nginx是完成此任务的好方法。 You need set Nginx proxy up on your domain. 您需要在您的域上设置Nginx代理。

Try using the nginx reverse proxy 尝试使用Nginx反向代理

An example Nginx server for your task would be: 用于您的任务的Nginx服务器示例为:

server {
    listen 80;
    server_name www.myapi.com;

    location / {
        proxy_pass      http://www.commercialapi.com;
        proxy_redirect  http://www.commercialapi.com/ /;
        proxy_read_timeout 60s;

        # Your can customize headers as well.
        proxy_set_header          X-Real-IP       $remote_addr;
        proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM