您的位置:首页 > 运维架构 > 反向代理

配置Squid遇到的问题和解决方法

2013-07-02 09:52 162 查看
1>发生了下列的错误:Invalid Request无效的请求Some aspect of the HTTP Request is invalid. Possible problems:HTTP 请求的某些方面是无效的。可能是下列问题:Missing or unknown request method缺少请求方式或未知的请求方式Missing URL缺少网址Missing HTTP Identifier (HTTP/1.0)缺少 HTTP 标识(HTTP/1.0)Request is too large请求命令过长Content-Length missing for POST or PUT requestsPOST 或 PUT 请求缺少内容长度Illegal character in hostname; underscores are not allowed主机名称中包含不合法的字符;下划线是不允许的。解答:在https_port 后加defaultsite=www.abc.com2》443端口不listening解答:证书不正确,请生成可以的证书
附加《1》:用下面命令可以生成测试用的证书:openssl req -new -keyout key.pem -nodes -x509 -days 365 -out cert.pem附加《2》:如果要生成一个证书请求用于申请正式证书请用下面两个命令:(1)、生成私钥 openssl genrsa -out key.pem 1024
(2)、生成待签名证书 openssl req -new -out req.csr -key key.pem然后将req.csr文件中的内容提交给证书颁发机构。
3》Unable to forward this request at this time解答:在配置中加下面一行cache_peer www.abc.com parent 80 0 no-query originserver

为了大家方便比较我贴出我的配置文件,供大家参考

http_port 80 transparent
https_port 443 defaultsite=www.abc.com cert=/usr/local/squid/zcxcert.pem key=/usr/local/squid/zcxkey.pem
icp_port 0
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \? \.aspx \.ashx \.asmx
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
cache_mem 512 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 8192 KB
maximum_object_size_in_memory 32 KB
cache_dir ufs /usr/local/squid/var/cache 2048 16 256
#access_log /usr/local/squid/var/logs/access.log common
access_log none
cache_log /usr/local/squid/var/logs/cache.log
#cache_store_log /usr/local/squid/var/logs/store.log
cache_store_log none
emulate_httpd_log on
pid_filename /usr/local/squid/var/logs/squid.pid
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
half_closed_clients off
acl all src 0.0.0.0/0.0.0.0
acl myip src 21.142.17.170 21.24.82.35
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl 252 dst 21.238.23.252
acl 251 dst 21.238.23.251
acl 233 dst 21.238.23.233
acl 237 dst 21.238.23.237
acl 234 dst 21.238.23.234
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmtacl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access allow manager myip
http_access allow 252
http_access allow 251
http_access allow 233
http_access allow 237
http_access allow 234
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_reply_access allow all
icp_access allow all
cache_mgr tech@abc.com
cache_effective_user nobody
cache_effective_group nobody
visible_hostname squid72
logfile_rotate 4
forwarded_for on
allow_underscore on
request_body_max_size 0 KB
coredump_dir /usr/local/squid/var/cache
cache_peer www.abc.com parent 80 0 no-query originserver4》启动squid时提示:"FATAL: Bungled squid.conf line xxx: cache_dir ufs /path/cache 256 16 256
Squid Cache (Version 2.5.STABLE13-xxxxxxxx):: Terminated abnormally."
解答:发现是因为存储缓存用的是aufs,启用这种格式必须在编译squid的时候加上async-io的支持,于是重新编译squid,加上async-io支持./configure –enable-async-io这里如果cache_dir不是设的ufs而是aufs的话,还需要加上参数–enable-storeio=aufs然后再make;make install再启动squid就OK了5》增大squid可使用的文件描述符解答:在RedHat AS4 (即kernel-2.6.9)里面用如下方法增大文件描述符:解压你下载的squid源码包# tar zxvf squid-2.6.STABLE XX .tar.gz (X表示版本号)# cd squid-2.6.STABLE XX# ulimit -Hn 16384 (16384 这个数值根据自己需要增大或者减小)# ./configure# make# make install根据自己需要编辑squid.conf要让squid使用之前已经编译时设置的文件描述符数量需要在每次启动squid之前先执行下面命令# ulimit -Hn 16384 (16384 这个数值根上面configure时设置一致)然后启动squid这样就增大了squid可使用的文件描述符6》忽略no-cache,reload指令解答:解压你下载的squid源码包,在squid.conf中添加refresh_pattern -i wdsl\.test\.cn 1440 50% 10080 ignore-reload ignore-no-cache

需要注意事项:
1>. 这一行要放在
refresh_pattern . 0 20% 4320

2>. 在 . (点) 之前要加斜线

原文地址:http://blog.chinaunix.net/uid-20489809-id-1665891.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐