內(nèi)外網(wǎng)環(huán)境,做了網(wǎng)絡(luò)隔離,只有一臺機器能夠訪問外網(wǎng)。
故在該機器上配置代理服務(wù)器,進(jìn)行代理轉(zhuǎn)發(fā)。
之前使用Nginx,但是發(fā)現(xiàn)nginx支持不了https的請求 (強行支持也行,需要裝一些額外包,源碼編譯,沒必要折騰)
這里記錄下一個Squid的快速配置安裝
安裝
可以采用多種方式安裝。裝好后,一般在/usr/sbin/squid 默認(rèn)配置文件是:/etc/squid/squid.conf
yum install squid
修改配置文件
如果沒有root權(quán)限,建議就在自己的目錄建一個squid.conf
copy一個下面的demo。 (這個是從默認(rèn)的/etc/squid/squid.conf里面復(fù)制出來的。)
一般情況下只需要修改下,
服務(wù)端口 http_port: 10000
日志文件路徑之類的。
如果沒有root權(quán)限,記得把里面的log路徑,pid路徑修改下。
#
# Recommended minimum configuration:
#
# Squid normally listens to port 3128
http_port 10000
# 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:
#
# 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
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
# 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
# And finally deny all other access to this proxy
http_access deny all
# 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
cache_mem 32 MB
cache_dir aufs /home/wxadmin/app/squid/cache/ 1024 16 256
access_log /home/wxadmin/app/squid/log/access.log
cache_log /home/wxadmin/app/squid/log/cache.log
pid_filename /home/wxadmin/app/squid/squid.pid
#
# 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
初始化/啟動/停止
squid需要進(jìn)行初始化才能使用。
-f 參數(shù)指定自定義配置文件。
一些常用命令。
#初始化
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf -z
# 開始
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf start
# 重啟
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf restart
# 關(guān)閉
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf -k shutdown
檢查
檢查端口,是否10000端口在服務(wù)。
netstat -lnp
檢查是否配置成功
curl -x 127.0.0.1:10000 https://www.baidu.com