gpt4 book ai didi

ruby-on-rails - 链接 Webrick 代理

转载 作者:太空宇宙 更新时间:2023-11-03 16:32:21 24 4
gpt4 key购买 nike

我一直在尝试测试 Webrick 代理的链接,但遇到了一些麻烦。

每个代理从 127.0.0.1:port 独立工作(当 :ProxyURI 被 proxy_2 注释掉时),但我收到错误:

ERROR unsupported method `GET'. 

当我尝试链接它们时,来自 proxy_2 输出 (httpproxy.rb)。

澄清一下,当我链接它们时,我使用 127.0.0.1:8086 作为我从另一个应用程序的访问点。

查看 proxy_1 的日志,它似乎没有收到任何请求。

如有任何帮助,我们将不胜感激。

require 'webrick'
require 'webrick/httpproxy'

port_1 = 8085
port_2 = 8086

proxy_1 =
WEBrick::HTTPProxyServer.new(
:Port => port_1,
:ServerType => Thread,
:Logger => WEBrick::Log.new("./logs/#{port_1}.out"),
:ServerName => "future_authentication_proxy"
)
proxy_1.start

proxy_2 =
WEBrick::HTTPProxyServer.new(
:Port => port_2,
:ProxyURI => '127.0.0.1:'+port_1.to_s
)
trap("INT"){
proxy_1.shutdown
proxy_2.shutdown
}
proxy_2.start

最佳答案

你传递了错误的 ProxyURI 选项,它应该是这样的:

:ProxyURI => URI.parse("http://#{host_1_ip}:#{port_1}/")

关于ruby-on-rails - 链接 Webrick 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13711120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com