Window client application 使用IE的http代理配置访问外网

本文介绍了如何在Windows客户端应用中使用IE的HTTP代理配置来访问外网,涉及PAC自动代理文件的编写、WPAD DAT文件的设置以及LibCurl库对代理的支持。还提到了Squid代理服务器的集成域身份认证和HTTP代理与SPDY协议的相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Window client application 使用IE的http代理配置访问外网


IE的proxy配置有3种:
1. 指定proxy server的ip和port
2. Automatically detect settings: WPAD
3. Use automatic configuration url: 指定PAC文件url


Firefox/Opera/Chrome都是使用IE的proxy配置.我们通过WinHttp DLL中的api可以拿到这个配置对应的proxy server和port.
Mac上可以使用系统设置里面的proxy setting,  CFProxySupport API.



WPAD是Web Proxy Auto Discovery的缩写,意思是Web代理服务器自动发现(通过dhcp/dns)
http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol


How does Windows actually detect LAN (proxy) settings when using Automatic Configuration:
http://stackoverflow.com/questions/191023/how-does-windows-actually-detect-lan-proxy-settings-when-using-automatic-confi


Detect Windows (IE) proxy settings changes: 
http://stackoverflow.com/questions/6192563/detect-windows-ie-proxy-settings-changes




Netsh.exe and ProxyCfg.exe Proxy Configuration Tools:
http://msdn.microsoft.com/en-us/library/aa384069%28v=VS.85%29.aspx




Using PAC(Proxy auto-config) files proxy:
http://www.codeproject.com/Articles/12168/Using-PAC-files-proxy




http://msdn.microsoft.com/en-us/library/aa384096(v=vs.85).aspx
window中使用WinHttp DLL中的WinHttpGetIEProxyConfigForCurrentUser:  retrieves the Internet Explorer proxy configuration for the current user.
This function is used by Firefox and Opera to get their proxy settings by default.


*********How do I find out the browser's proxy settings?:
http://stackoverflow.com/questions/202547/how-do-i-find-out-the-browsers-proxy-settings


PAC自动代理文件格式,教你如何写PAC文件

http://www.truevue.org/javascript/pac-format



iOS/OS X使用cfproxysupport来拿到系统的proxy configuration.



wpad.dat文件需要放在web server根目录下, 并设content-type为application/x-ns-proxy-autoconfig

wpad.dat文件的内容格式如下:

function FindProxyForURL(url, host) {
    if (shExpMatch(host, “127.*”)
        || shExpMatch(host, “localhost”)
        //|| shExpMatch(url, “*.tahubachem.net/*”)
        || isPlainHostName(host)
        //|| dnsDomainIs(host, “.tahubachem.net”))
    {
      return “DIRECT”;
    }else{
      return “PROXY X.X.X.x:8080; DIRECT;”;
      // return “PROXY 123.123.123.123:8080; DIRECT;”;
    }
}



LibCurl also support proxy already:

CURLOPT_PROXYTYPE

Pass a long with this option to set type of the proxy. Availableoptions for this are CURLPROXY_HTTPCURLPROXY_HTTP_1_0(added in 7.19.4), CURLPROXY_SOCKS4 (added in 7.10), CURLPROXY_SOCKS5CURLPROXY_SOCKS4A (added in 7.18.0) and CURLPROXY_SOCKS5_HOSTNAME (added in 7.18.0). The HTTP type isdefault. (Added in 7.10)

If you set CURLOPT_PROXYTYPE to CURLPROXY_HTTP_1_0, it will only affect howlibcurl speaks to a proxy when CONNECT is used. The HTTP version used for"regular" HTTP requests is instead controlled with CURLOPT_HTTP_VERSION.

 

http://curl.haxx.se/libcurl/c/curl_easy_setopt.html



libcurl支持通过window SSPI 读取当前登录的域用户来进行代理的NTLM验证.

http://stackoverflow.com/questions/1276955/ntlm-proxy-without-password?rq=1



配置squid集成域身份认证:  http://penglei.name/html/337.html

域环境下配置squid的IE代理自动检测设置: http://penglei.name/html/341.html


HTTP代理与SPDY协议: http://blog.jobbole.com/42763/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值