特别鸣谢
10分钟搭建linux代理服务器_三雷科技的博客-CSDN博客
Windows7/10/11 Pac代理脚本及配置_pac脚本_ylf尘风的博客-CSDN博客
1. 代理服务器搭建
yum install tinyproxy
代理服务器,配置
编辑配置/etc/tinyproxy/tinyproxy.conf:
(1)找到Allow 127.0.0.1行,前面加上#号将其注释掉。
(2)Port 8888:默认开放的端口为8888(可自行更改)
执行/etc/init.d/tinyproxy restart使配置生效,或者执行systemctl restart tinyproxy.service
2.客户端windows pac配置
脚本编写proxy.pac
function FindProxyForURL(url, host) {
var proxy = "PROXY 192.168.2.190:8888";
//本地地址直接连接
if (isPlainHostName(host)) {
return "DIRECT";
}
// 代理
if (shExpMatch(url, "*baidu.com*")) {
return proxy;
}
}
//没有匹配上的都直接连接
return "DIRECT";
}
1).修改注册表
以下内容保为pac.reg,双击。或手动修改注册表。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings]
"EnableLegacyAutoProxyFeatures"=dword:00000001
2).修改自动配置脚本的地址类似
例子中proxy.pac文件放在e盘根目录。需要根据具体情况修改。
file://c:\proxy.pac
配置重启生效(可选)
@echo off
color 0a
title Use autoconfig script
echo Starting......
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v DefaultConnectionSettings /t REG_BINARY /d 46000000020000000900 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v SavedLegacySettings /t REG_BINARY /d 46000000020000000900 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /d "file://c:\proxy.pac" /f
echo End
@echo off
如果脚本访问不到,可以使用everything解决