【问题标题】:add http request header to http request header from openwrt将http请求标头添加到来自openwrt的http请求标头
【发布时间】:2015-06-08 15:45:01
【问题描述】:

来自我的 openwrt 路由器的所有 http 流量现在都重定向到代理服务器 http://proxyserver:7117

我想为每个 http 请求添加一个自定义的 http 请求标头,以便代理服务器可以知道产生流量的源路由器。

除了在本地openwrt安装代理包,有什么办法吗?

【问题讨论】:

    标签: openwrt


    【解决方案1】:

    Openwrt 对一般配置中的 http 流量一无所知。我的建议是:您应该调整 iptables 以将所有 http 流量(80,8080 等)重定向到可以修改 http 标头的本地代理,然后将所有修改后的包重新传输到远程代理服务器。试试这个本地代理服务器:http://wiki.openwrt.org/doc/howto/proxy.privoxy

    这是您需要的示例: http://www.privoxy.org/user-manual/actions-file.html#ADD-HEADER

    !此解决方案仅适用于 http 流量(不是 https)

    【讨论】:

    • 有没有办法向 https 流量注入类似 id 的东西?
    • 没有简单的方法可以在 5 分钟内完成。您可以尝试深入研究 https 规范、密钥交换、证书验证等。
    【解决方案2】:

    有一种方法可以在 Python 中完成,但我不确定它是否适合您。

    如果有帮助: 使用 urllib2 库并附加标题如下(例如):

    import urllib2 request = urllib2.Request("http://proxyserver:7117") request.add_header("Source-router", "router_1") urllib2.urlopen(request,实际数据)

    add_header(key, value)方法:https://docs.python.org/2/library/urllib2.html#urllib2.Request.add_header

    【讨论】:

      猜你喜欢
      • 2012-12-01
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-07
      • 2015-07-13
      相关资源
      最近更新 更多