无法让 Squid 在 CentOS 上运行

无法让 Squid 在 CentOS 上运行

我已经在我的 centos vps 服务器上设置了 squid,并且我尝试通过我的 windows 计算机连接到它,但是我在所有网站上都收到以下错误:

等待 google.com

代理服务器没有响应

我按照以下教程设置了 squid:

如何在 CentOS 6 上安装 Squid 代理

我的 squid 配置文件:

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

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-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
http_access allow all

# And finally deny all other access to this proxy
# http_access deny all

# Squid normally listens to port 3128
http_port 3128

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

visible_hostname myproxy

谢谢。

更新 :

访问日志:

1431455471.946   1136 61.160.213.33 TCP_MISS/200 654 GET http://zc.qq.com/cgi-bin/chs/numreg/init? - DIRECT/163.177.56.115 application/json
1431455540.816    711 104.217.55.135 TCP_MISS/200 321 GET http://zc.qq.com/chs/ver.js? - DIRECT/163.177.56.115 application/x-javascript
1431455567.306   1901 118.193.158.165 TCP_MISS/200 296 POST http://zc.qq.com/cgi-bin/en/othmailreg/get_acc? - DIRECT/163.177.56.115 text/html
1431455569.419   1813 118.193.158.165 TCP_MISS/302 401 GET http://zc.qq.com:443/cgi-bin/common/new_router - DIRECT/163.177.56.115 text/html
1431455571.911   1731 118.193.158.165 TCP_MISS/200 321 GET http://zc.qq.com/en/ver.js? - DIRECT/163.177.56.115 application/x-javascript
1431455573.040    812 118.193.158.165 TCP_MISS/200 650 GET http://zc.qq.com/cgi-bin/en/othmailreg/init? - DIRECT/163.177.56.115 text/html
1431455574.177    402 118.193.158.165 TCP_MISS/200 278 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455575.491    995 118.193.158.165 TCP_MISS/200 1172 GET http://a.zc.qq.com/s.js? - DIRECT/112.90.140.50 application/x-javascript
1431455576.624    814 118.193.158.165 TCP_MISS/200 278 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455577.335    404 118.193.158.165 TCP_MISS/200 278 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455578.508    817 118.193.158.165 TCP_MISS/200 278 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455580.627   1630 118.193.158.165 TCP_MISS/200 3337 GET http://captcha.qq.com/getimage? - DIRECT/112.90.83.73 image/jpeg
1431455581.868    420 118.193.158.165 TCP_MISS/200 277 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455582.878    679 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/SecCheck? - DIRECT/112.90.140.50 text/html
1431455583.736    415 118.193.158.165 TCP_MISS/200 1859 GET http://zc.qq.com/en/m.js? - DIRECT/163.177.56.115 application/x-javascript
1431455584.449    416 118.193.158.165 TCP_MISS/200 407 GET http://zc.qq.com/cgi-bin/en/qqmailreg/init? - DIRECT/163.177.56.115 text/html
1431455585.157    411 118.193.158.165 TCP_MISS/200 278 GET http://zc.qq.com/cgi-bin/common/attr? - DIRECT/163.177.56.115 text/html
1431455586.884   1313 118.193.158.165 TCP_MISS/200 3190 GET http://captcha.qq.com/getimage? - DIRECT/112.90.83.73 image/jpeg
1431455592.194    426 118.193.158.165 TCP_MISS/200 263 GET http://zc.qq.com/cgi-bin/en/qqmailreg/check_mail? - DIRECT/163.177.56.115 text/html
1431455602.604    720 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455604.194   1183 118.193.158.165 TCP_MISS/200 3292 GET http://captcha.qq.com/getimage? - DIRECT/112.90.83.73 image/jpeg
1431455605.522    417 118.193.158.165 TCP_MISS/200 263 GET http://zc.qq.com/cgi-bin/en/common/dirty_check? - DIRECT/163.177.56.115 text/html
1431455614.890    725 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455625.578    708 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455636.193    671 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455638.130    699 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455640.090    772 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455642.064    698 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455643.987    716 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455645.950    691 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455648.077    686 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455649.761    688 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455651.738    804 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455653.636    825 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455655.591    705 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455664.751    682 118.193.158.165 TCP_MISS/200 248 GET http://a.zc.qq.com/Cgi-bin/MoniKey? - DIRECT/112.90.140.50 text/html
1431455670.522   5242 118.193.158.165 TCP_MISS/200 1608 POST http://zc.qq.com/cgi-bin/en/qqmailreg/get_acc? - DIRECT/163.177.56.115 text/html
1431455922.382   1333 222.172.93.221 TCP_MISS/200 513 GET http://zc.qq.com/cgi-bin/chs/numreg/init? - DIRECT/163.177.56.115 application/json
1431456134.184   1248 61.160.213.33 TCP_MISS/200 654 GET http://zc.qq.com/cgi-bin/chs/numreg/init? - DIRECT/163.177.56.115 application/json
1431456182.329    745 59.174.88.27 TCP_MISS/200 513 GET http://zc.qq.com/cgi-bin/chs/numreg/init? - DIRECT/163.177.56.115 application/json

缓存日志:

2015/05/12 14:24:46| Loaded Icons.
2015/05/12 14:24:46| Accepting  HTTP connections at [::]:3128, FD 14.
2015/05/12 14:24:46| HTCP Disabled.
2015/05/12 14:24:46| WARNING: 'myproxy' rDNS test failed: (14) Bad address
2015/05/12 14:24:46| WARNING: Could not determine this machines public hostname. Please configure one or set 'visible_hostname'.
2015/05/12 14:24:46| Squid plugin modules loaded: 0
2015/05/12 14:24:46| Adaptation support is off.
2015/05/12 14:24:46| Ready to serve requests.
2015/05/12 14:24:47| storeLateRelease: released 0 objects
2015/05/12 14:26:00| Preparing for shutdown after 0 requests
2015/05/12 14:26:00| Waiting 30 seconds for active connections to finish
2015/05/12 14:26:00| FD 14 Closing HTTP connection
2015/05/12 14:26:31| Shutting down...
2015/05/12 14:26:31| basic/auth_basic.cc(97) done: Basic authentication Shutdown.
2015/05/12 14:26:31| Closing unlinkd pipe on FD 13
2015/05/12 14:26:31| storeDirWriteCleanLogs: Starting...
2015/05/12 14:26:31|   Finished.  Wrote 0 entries.
2015/05/12 14:26:31|   Took 0.00 seconds (  0.00 entries/sec).
CPU Usage: 0.097 seconds = 0.046 user + 0.051 sys
Maximum Resident Size: 42272 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
    total space in arena:    3528 KB
    Ordinary blocks:         3501 KB      4 blks
    Small blocks:               0 KB      6 blks
    Holding blocks:          1096 KB      4 blks
    Free Small blocks:          0 KB
    Free Ordinary blocks:      26 KB
    Total in use:            4597 KB 130%
    Total free:                27 KB 1%
2015/05/12 14:26:31| Open FD UNSTARTED     7 DNS Socket IPv6
2015/05/12 14:26:31| Open FD UNSTARTED     8 DNS Socket IPv4
2015/05/12 14:26:31| Squid Cache (Version 3.1.10): Exiting normally.
2015/05/12 14:26:32| Starting Squid Cache version 3.1.10 for x86_64-redhat-linux-gnu...
2015/05/12 14:26:32| Process ID 1233
2015/05/12 14:26:32| With 1024 file descriptors available
2015/05/12 14:26:32| Initializing IP Cache...
2015/05/12 14:26:32| DNS Socket created at [::], FD 7
2015/05/12 14:26:32| DNS Socket created at 0.0.0.0, FD 8
2015/05/12 14:26:32| Adding nameserver 8.8.4.4 from /etc/resolv.conf
2015/05/12 14:26:32| Adding nameserver 8.8.8.8 from /etc/resolv.conf
2015/05/12 14:26:32| Adding nameserver 209.244.0.3 from /etc/resolv.conf
2015/05/12 14:26:32| User-Agent logging is disabled.
2015/05/12 14:26:32| Referer logging is disabled.
2015/05/12 14:26:32| Unlinkd pipe opened on FD 13
2015/05/12 14:26:32| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2015/05/12 14:26:32| Store logging disabled
2015/05/12 14:26:32| Swap maxSize 0 + 262144 KB, estimated 20164 objects
2015/05/12 14:26:32| Target number of buckets: 1008
2015/05/12 14:26:32| Using 8192 Store buckets
2015/05/12 14:26:32| Max Mem  size: 262144 KB
2015/05/12 14:26:32| Max Swap size: 0 KB
2015/05/12 14:26:32| Using Least Load store dir selection
2015/05/12 14:26:32| Set Current Directory to /var/spool/squid
2015/05/12 14:26:32| Loaded Icons.
2015/05/12 14:26:32| Accepting  HTTP connections at [::]:3128, FD 14.
2015/05/12 14:26:32| HTCP Disabled.
2015/05/12 14:26:32| Squid plugin modules loaded: 0
2015/05/12 14:26:32| Adaptation support is off.
2015/05/12 14:26:32| Ready to serve requests.
2015/05/12 14:26:33| storeLateRelease: released 0 objects
2015/05/12 14:40:38| Preparing for shutdown after 38 requests
2015/05/12 14:40:38| Waiting 30 seconds for active connections to finish
2015/05/12 14:40:38| FD 14 Closing HTTP connection
2015/05/12 14:41:10| Shutting down...
2015/05/12 14:41:10| basic/auth_basic.cc(97) done: Basic authentication Shutdown.
2015/05/12 14:41:10| Closing unlinkd pipe on FD 13
2015/05/12 14:41:10| storeDirWriteCleanLogs: Starting...
2015/05/12 14:41:10|   Finished.  Wrote 0 entries.
2015/05/12 14:41:10|   Took 0.00 seconds (  0.00 entries/sec).
CPU Usage: 0.289 seconds = 0.167 user + 0.122 sys
Maximum Resident Size: 43312 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
    total space in arena:    3644 KB
    Ordinary blocks:         3604 KB     19 blks
    Small blocks:               0 KB      6 blks
    Holding blocks:          1096 KB      4 blks
    Free Small blocks:          0 KB
    Free Ordinary blocks:      39 KB
    Total in use:            4700 KB 129%
    Total free:                39 KB 1%
2015/05/12 14:41:10| Open FD UNSTARTED     7 DNS Socket IPv6
2015/05/12 14:41:10| Open FD READ/WRITE    8 DNS Socket IPv4
2015/05/12 14:41:10| Squid Cache (Version 3.1.10): Exiting normally.
2015/05/12 14:41:10| Starting Squid Cache version 3.1.10 for x86_64-redhat-linux-gnu...
2015/05/12 14:41:10| Process ID 1279
2015/05/12 14:41:10| With 1024 file descriptors available
2015/05/12 14:41:10| Initializing IP Cache...
2015/05/12 14:41:10| DNS Socket created at [::], FD 7
2015/05/12 14:41:10| DNS Socket created at 0.0.0.0, FD 8
2015/05/12 14:41:10| Adding nameserver 8.8.4.4 from /etc/resolv.conf
2015/05/12 14:41:10| Adding nameserver 8.8.8.8 from /etc/resolv.conf
2015/05/12 14:41:10| Adding nameserver 209.244.0.3 from /etc/resolv.conf
2015/05/12 14:41:10| User-Agent logging is disabled.
2015/05/12 14:41:10| Referer logging is disabled.
2015/05/12 14:41:10| Unlinkd pipe opened on FD 13
2015/05/12 14:41:10| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2015/05/12 14:41:10| Store logging disabled
2015/05/12 14:41:10| Swap maxSize 0 + 262144 KB, estimated 20164 objects
2015/05/12 14:41:10| Target number of buckets: 1008
2015/05/12 14:41:10| Using 8192 Store buckets
2015/05/12 14:41:10| Max Mem  size: 262144 KB
2015/05/12 14:41:10| Max Swap size: 0 KB
2015/05/12 14:41:10| Using Least Load store dir selection
2015/05/12 14:41:10| Set Current Directory to /var/spool/squid
2015/05/12 14:41:10| Loaded Icons.
2015/05/12 14:41:10| Accepting  HTTP connections at [::]:3128, FD 14.
2015/05/12 14:41:10| HTCP Disabled.
2015/05/12 14:41:10| Squid plugin modules loaded: 0
2015/05/12 14:41:10| Adaptation support is off.
2015/05/12 14:41:10| Ready to serve requests.
2015/05/12 14:41:11| storeLateRelease: released 0 objects

netstat -nltap | grep LIS 输出:

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                                          ESTABLISHED 1112/sshd
tcp        0      0 :::22                       :::*                        LISTEN      933/sshd
tcp        0      0 :::3128                     :::*                        LISTEN      1279/(squid)
tcp        0      0 ::1:25                      :::*                        LISTEN      1010/master

答案1

除了日志之外,还要检查其他一些东西

  1. 本地防火墙(iptables)
  2. squid 是否正在监听其他服务器可以访问的外部 IP?
    netstat -nltap | grep LIS
  3. (如 1),使用 nc 或 telnet 验证您是否可以从客户端访问默认值squid port 3128telnet squidserver 3128,有任何回应吗?

答案2

如果端口被阻止:

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3128 -j ACCEPT 
iptables-save > /etc/sysconfig/iptables 

我从 Bitrix Virtual Appliance 中得到了这个想法:

https://training.bitrix24.com/support/training/course/?COURSE_ID=113&LESSON_ID=19986

相关内容