squid反向代理配置中如何指定上游服务器是网站源主机

发布时间:2019-08-27 17:02:14

squid反向代理配置中如何指定上游服务器是网站源主机

推荐回答

Squid主要设计用于在Linux一类系统运行。

1.squid代理:

yum install squid  #安装的是squid3.x版的

vi /etc/squid/squid.conf添加如下(注意顺序,尽量排在顶端)acl localnet src 192.168.1.0/32    #定义你的源本地网段或者IP  acl dst_net  dst 8.8.8.8  www.linuxidc.  #定义代理可以访问的目标IP、域名、网段

http_access  allow  localnet    #允许localnet 定义的源可以通过代理访问  

http_access  deny    !dst_net    #拒绝访问 不是dst_net定义的目标地址,即只能访问dst_net#http_port =3128  默认监听端口3128 ,#http_access默认拒绝所有,即没有匹配到任何一项,就拒绝然后在你的客户IE设置代理IP和端口,如下图:

xxxxxx

2.squid反向代理:

vi /etc/squid/squid.conf

添加acl和http_access 允许所有访问

在http_port=80 设置监听端口80,然后在下面添加

cache_peer 192.168.1.156 parent 8000  0  name=a  #设置多个后台IP和端口,另加一行

cache_peer_domain a www.linuxidc.  #多个域名空格隔开出现下面错误:

ERROR

The requested URL could not be retrieved

--------------------------------------------------------------------------------

The following error was encountered while trying to retrieve the URL: /

Invalid URL

Some aspect of the requested URL is incorrect.

Some possible problems are:

Missing or incorrect access protocol (should be “http://” or similar)

Missing hostname

Illegal double-escape in the URL-Path

Illegal character in hostname; underscores are not allowed.

Your cache administrator is root.

出现上面的错误,需要修改下:

http_port 80  defaultsite=www.linuxidc.

cache_peer 192.168.1.156 parent 8000  0  no-query originserver weight=1 name=a

cache_peer_domain a www.linuxidc.

或者:(推荐)

http_port 80 transparent

cache_peer 192.168.1.156 parent 8000  0 no-query originserver  name=a

cache_peer 192.168.1.144 parent 80  0 no-query originserver  name=b

cache_peer_domain a www.linuxidc.

cache_peer_domain b www.linuxidc.net

然后重新访问正常

2.反向代理Access Denied Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.这样的错误,需要在客户端取消代理,即:不使用任何代理,解决。

以上问题属网友观点,不代表本站立场,仅供参考!