问题描述
我正在尝试编写一个代理服务器,如果它与模式匹配,它能够重新写入 url。
示例: 请求
curl https://example.com --proxy http://localhost:1234
我希望代理服务器改为请求 http://localhost:5000/p/https://example.com
,这也是我编写的另一个 Flask 代理,它对请求 URL 时要获取的页面有很多规则。
我已经尝试了几种解决堆栈溢出的方法,但大多数在使用 https 时都彻底失败或失败。
示例
from twisted.web import proxy,http
from twisted.internet import reactor
from twisted.python import log
import sys
log.startLogging(sys.stdout)
class ProxyFactory(http.HTTPFactory):
protocol = proxy.Proxy
reactor.listenTCP(8080,ProxyFactory())
reactor.run()
这需要 http 而不是 https。
我认为我可以通过 https://github.com/abhinavsingh/proxy.py#redirecttocustomserverplugin 实现这一目标 但我花了几个小时试图弄清楚但失败了
tldr:编写一个代理服务器,对 https 进行降级,并使用自定义 url 重写请求的 url。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)