Ngnix/Squid/Apache 都支持http的正向代理,目前已经成功的配置了Squid和Apache,经过一段时间的使用,发现apache比较稳定。
以下是尝试过的方法:
Apache
版本2.4,在site-enabled下增加proxy.conf配置文件:
<VirtualHost ProxyIP:ProxyPort>
ServerName Proxy域名
ProxyRequests On
ProxyVia On
ErrorLog ${APACHE_LOG_DIR}/proxy.error.log
CustomLog ${APACHE_LOG_DIR}/proxy.access.log combined
</VirtualHost>
另外,还需启用mod_proxy/mod_proxy_http/mod_proxy_connect等模块,执行:
a2enmod proxy
a2enmod proxy_http
a2enmod connect
最后重启apache
再进一步,加入代理验证
由于basic验证相当于明文传输密码,所以选用digest验证,需要启用mod_auth_digest模块,执行:
a2enmod auth_digest
重启apache
其次,再用htdigest工具生成包含密码信息的验证文件:
htdigest -c 文件路径 realm 用户名
其中,如果找不到htdigest则需要安装apache2-util,realm对应配置文件中的AuthName字段
最后在apache配置文件中加入:
<Proxy *>
AuthType Digest
AuthName “htdigest中输入的realm”
AuthDigestProvider file
AuthUserFile 验证文件路径
Require vaild-user
</Proxy>
重启apache
Squid
参见Squid搭建正向代理(链接)
Nginx
(无)