首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我的代理应该如何拦截数据包

我的代理应该如何拦截数据包
EN

Stack Overflow用户
提问于 2016-12-20 22:52:51
回答 1查看 170关注 0票数 0

我有两个web服务器AC。由于规则、策略等原因,A无法与C' (C直接通信,requires requests to have special security headers anda`不支持)

我想创建一个在Java语言中称为B的“代理”,以促进AB之间的通信,但我在概念上遇到了问题。

创建代理时,是否必须更改所有服务上的硬编码URL才能通过代理?然后,我想您必须以某种方式将目的地作为查询参数进行传递,例如

代码语言:javascript
复制
http://proxy.com/?destination=mydestination.com

这就是代理的工作方式吗?

(我发现了一些类似的问题,但它们并没有解决我遇到的基本问题,即How packets reaches Destination throgh proxy servers?)

EN

Stack Overflow用户

发布于 2016-12-20 23:40:16

不要从头开始编写自己的代理,这将是重做,有大量的代理实现

Spring框架

(Netflex/Zuul) https://github.com/Netflix/zuul / https://spring.io/guides/gs/routing-and-filtering/

  • Spring Boot实现

标准Servlet

如果您对如何构建自己的代理感兴趣,这里有一个使用spring框架的简单示例(Servlet实现与spring实现相差不远)。

代码语言:javascript
复制
@RestController
public class ProxyController {

/**
 * request handler for all the requests on the registered context intended to be proxied
 *
 * @param request
 * @return
 */
@RequestMapping("/**")
public String defaultGateway(HttpServletRequest request) {
    // edit the original request headers,body etc
    String originalPath =  request.getRequestURI();
    // then fire another HTTP request using the same URI
    return "ProxiedResult"; // return back the result you get from
 }
}

上面的例子是一个关于如何实现HTTP代理或它是如何工作的起点,有许多东西需要涵盖,例如安全性

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41245116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档