Squid Proxy Authentication fails


Squid Proxy Authentication fails

我按照本教程设置代理服务器。安装Squid和apache2-utils

使用htpasswd创建用户名和密码

sudo htpasswd /etc/squid3/squid_passwd myusername

将以下行添加到squid.conf

auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/squid_passwd
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

重启squid服务器。并在cmd中检查用户名和密码。Ok

/usr/lib/squid3/ncsa_auth /et/squid3/squid_passwd
myusername password
OK

但是我不能从PHP访问

$proxy = "111.11.11.11:8220"; // my squid ip and port
$proxyauth =   base64_encode('username:pass');   // Tried without base64_encode also  
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD,  $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
echo $curl_scraped_page;
if(curl_error($ch))
{
    echo 'error:' . curl_error($ch);
}
curl_close($ch);

但是我得到X-Squid-Error: ERR_ACCESS_DENIED error

您使用了错误的身份验证库来访问密码文件

auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/squid_passwd

应该是

auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd

我有这个问题,当我创建代理服务器https://createproxy.com

经过2次完全重写和200次错误尝试后,我将squid用户名更改为仅包含字符(没有数字混合字符串)。它开始工作了!直到今天我还不知道为什么你只需要使用字符作为squid的用户名