企业代理背后的 Apache
Apache behind corporate proxy
我正在开发 php 应用程序。我正在使用 wamp 并且我在公司代理后面。我正在使用 cntlm to authenticate NTLM。我需要 curl google 地理编码 api,为此我使用了以下有效的设置:
curl_setopt($ch,CURLOPT_PROXY, '127.0.0.1:3128');
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
我想找到一种方法来避免为 CURL 设置这些选项。我相信我可以玩 Apache 设置,但我不确定。我需要找到此解决方案的原因是:
- 在生产环境中不会有这样的代理(目前只有在环境变量设置为DEV env时才使用上述选项,但仍然:这不是最好的解决方案)
- 如果我想使用第 3 方 SDK(例如 facebook php sdk),它们在内部使用 CURL 但它们不一定公开更改 CURL 选项的方法(例如 facebook sdk 没有) .我不想更改 SDK 源代码以适合我的代理
我尝试了什么:
到目前为止,我在 apache 上打开了 proxy_module,并在 httpd.conf 上添加了以下行,但没有成功
ProxyRemote * http://127.0.0.1:3128
我仍然无法访问互联网。我 google 找了很多,但找不到解决方案,有什么想法吗?
我发现很多人都在谈论同一个问题,但我没有找到任何全面的解决方案,因此我提出了悬赏。
我发现了什么:
我发现 this bug:但我不确定这是否适用于 curl,而且我找不到如何修改 php.ini
[2010-12-20 14:03 UTC]
jani@php.net
-Summary: changing the default http-wrapper
+Summary: Add php.ini option to set default proxy for wrappers
-Package: Feature/Change Request
+Package: Streams related
-PHP Version: 5CVS
+PHP Version: *
和
[2011-04-05 11:29 UTC] play4fun_82 at yahoo dot com Hi, i have the
same problem. My solution was to pass through proxy server with cntml
tunneling tool. You configure cntml proxy to forward http request
received on local host on a port to destination with proper
authentication.
And in pear u just configure
pear config-set http_proxy 127.0.0.1:3128
3128 - 是 cntlm 中的端口配置(它可以是任何其他空闲端口)。
非常感谢
你是说你想要 WAMP 上的这个功能,只用于你的开发计算机,对吧? SDK 在生产中无需修改即可工作,因此您可以利用 Window 的主机文件重定向请求。
我认为您可以通过 Proxifier(http://www.proxifier.com) 等代理工具来完成。
据我所知,他们可以捕获来自选定应用程序的流量并自动重定向到代理。
不是一个完美的解决方案,但应该对开发机器有用。
看完后this article I was about to throw in the towel, but there is actually an easy solutiuon. I had to play with windows environment variable, at the end setting a system variable to https_proxy=https://localhost:3128成功了!在它不起作用之前,因为我将它设置为 127.0.0.1:3128。 运行 命令
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"
然后 copy/paste 系统变量中的答案,现在可以使用了!!
我正在开发 php 应用程序。我正在使用 wamp 并且我在公司代理后面。我正在使用 cntlm to authenticate NTLM。我需要 curl google 地理编码 api,为此我使用了以下有效的设置:
curl_setopt($ch,CURLOPT_PROXY, '127.0.0.1:3128');
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
我想找到一种方法来避免为 CURL 设置这些选项。我相信我可以玩 Apache 设置,但我不确定。我需要找到此解决方案的原因是:
- 在生产环境中不会有这样的代理(目前只有在环境变量设置为DEV env时才使用上述选项,但仍然:这不是最好的解决方案)
- 如果我想使用第 3 方 SDK(例如 facebook php sdk),它们在内部使用 CURL 但它们不一定公开更改 CURL 选项的方法(例如 facebook sdk 没有) .我不想更改 SDK 源代码以适合我的代理
我尝试了什么:
到目前为止,我在 apache 上打开了 proxy_module,并在 httpd.conf 上添加了以下行,但没有成功
ProxyRemote * http://127.0.0.1:3128
我仍然无法访问互联网。我 google 找了很多,但找不到解决方案,有什么想法吗?
我发现很多人都在谈论同一个问题,但我没有找到任何全面的解决方案,因此我提出了悬赏。
我发现了什么:
我发现 this bug:但我不确定这是否适用于 curl,而且我找不到如何修改 php.ini
[2010-12-20 14:03 UTC] jani@php.net -Summary: changing the default http-wrapper +Summary: Add php.ini option to set default proxy for wrappers -Package: Feature/Change Request +Package: Streams related -PHP Version: 5CVS +PHP Version: *
和
[2011-04-05 11:29 UTC] play4fun_82 at yahoo dot com Hi, i have the same problem. My solution was to pass through proxy server with cntml tunneling tool. You configure cntml proxy to forward http request received on local host on a port to destination with proper authentication.
And in pear u just configure
pear config-set http_proxy 127.0.0.1:3128
3128 - 是 cntlm 中的端口配置(它可以是任何其他空闲端口)。
非常感谢
你是说你想要 WAMP 上的这个功能,只用于你的开发计算机,对吧? SDK 在生产中无需修改即可工作,因此您可以利用 Window 的主机文件重定向请求。
我认为您可以通过 Proxifier(http://www.proxifier.com) 等代理工具来完成。
据我所知,他们可以捕获来自选定应用程序的流量并自动重定向到代理。
不是一个完美的解决方案,但应该对开发机器有用。
看完后this article I was about to throw in the towel, but there is actually an easy solutiuon. I had to play with windows environment variable, at the end setting a system variable to https_proxy=https://localhost:3128成功了!在它不起作用之前,因为我将它设置为 127.0.0.1:3128。 运行 命令
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"
然后 copy/paste 系统变量中的答案,现在可以使用了!!