title: 网络代理知识整理2
cover: 'https://tuapi.eees.cc/api.php?category=dongman&type=302'
abbrlink: 6c486616
date: 2022-11-06 14:15:12

tags:

网络代理

  1. 了解网络七层与五层模型,了解虚拟专用网

  2. 了解代理历史,及代理软件的发展历史

  3. 了解代理的类型

代理历史

  1. 防火墙与安全

  2. 缓存,减轻压力

代理类型

正向代理:浏览器pc机 》代理机 》互联网; 需要在PC机与代理机进行代理协议设定,以便后续交流

反向代理:浏览器pc机 》代理机 》互联网;不需要在PC机与代理机进行代理协议设定,对于PC机来说,浏览器输入代理机网址就是互联网网址(目标机)

透明代理:    与正向代理不同,不需要设定client? 还是要设定客户端的网关吧?只是比正向代理从软件设置到了由网关进行重写与路由转发;用户没有设置,或者软件感知不到,所以是透明的?

一学就会的Squid三种代理模式(正向、反向、透明_戴尔服务器价格_IBM联想配置_浪潮代理-深圳市硕远科技有限公司

像clash 这种访问外网的软件,tun 网关(透明代理)? 加反代(转到真正的外网目标机);

主要体现有网络的第几层,及协议类型与网络拓扑;

代理软件

Squid权威指南

代理软件

代理服务器及(squid/lvs/nginx/haproxy)比较_水晶兰~的博客-CSDN博客_haproxy squid

squid:     比较老了;支持正向,反向,等;

lvs: 工作在网络4层

nginx:工作在七层,也有工作在4层的情景与模块;

haproxy:工作在4,7层;

win

win server版本 netsh工具

官方使用文档:

Netsh 的 interface portproxy 命令 | Microsoft Learn

Windows自带的端口转发工具netsh使用方法 - 好耶数据 (yeidc.com)

netsh工具需要管理员权限

下面的代码在windows下运行后可以讲27.155.88.1的14841端口转发到27.155.88.2的3389端口上

netsh interface ipv6 install XP之后的系统,就不需要这个命令
netsh interface portproxy add v4tov4 listenaddress=27.155.88.1 listenport=14841 connectaddress=27.155.88.2 connectport=3389

如果要取消上面的端口转发,使用下面的代码

netsh interface portproxy delete v4tov4 listenaddress=27.155.88.1 listenport=14841

如果想查看已经配置了哪些端口转发,可以用如下语句:

netsh interface portproxy show v4tov4

Netsh 命令語法、內容與格式 | Microsoft Learn

使用 netsh http 查詢和設定 HTTP.sys 設定和參數。

如果您在執行 Windows Server 或 Windows 10 的電腦上使用 Windows PowerShell,請輸入netsh ,然後按 enter 鍵。 在 netsh 提示字元中輸入 http,然後按 Enter 鍵,以取得 netsh http 提示字元。

意思是进行这个http的上下文进行操作,进行交互命令行,会使得命令简短

即执行netsh操作的那台机器,必须处在目标边界 ??

边界跨越简易入门 Windows 运维工具 netsh // Neurohazard (blkstone.github.io)

  1. 如果目标的系统实时监控防火墙规则的变动(例如主机有agent实时监控,与监控服务器存在心跳联系),这么做极易触发告警,隐蔽性非常差。

netsh http show servicestate

it will show you a list of Server Session with the URL they registered:

在应用层面:注册http.sys的url,然后delegation:委托;是的http.sys是一种内核层级

Http.sys Delegation

Http.sys delegation is a kernel level feature added into newer versions of Windows which allows a request to be transferred from the receiving process's http.sys queue to a target process's http.sys queue with very little overhead or added latency. For this delegation to work, the receiving process is only allowed to read the request headers. If the body has started to be read or a response has started, trying to delegate the request will fail. The response will not be visible to the proxy after delegation, which limits the functionality of the session affinity and passive health checks components, as well as some of the load balancing algorithms. Internally, YARP leverage's ASP.NET Core's IHttpSysRequestDelegationFeature

Http.sys delegation requires:

header guidelines

X-http-method-override, x-http-method, x-method-override

X-Forwarded-*, Forwarded

https://microsoft.github.io/reverse-proxy/articles/header-guidelines.html

了解一下;

X-Forwarded-For - HTTP | MDN (mozilla.org)

HTTP 标头和经典负载均衡器 - 弹性负载均衡 (amazon.com)