Menu

SQUID 프록시 서버 설치 방법

프록시 서버를 실행하는 가장 빠른 방법은 도커를 이용하는 방법입니다.

docker run --name squid -p 3128:3128 --rm -d \
  -e PROXYLOGIN=mylogin \
  -e PROXYPASSWORD=mypassword \
  anticaptcha/squid

자체 환경설정 파일을 설정하고 싶다면, 인증을 설정하는 곳에서 /etc/squid/squid.conf로 설정하세요.

docker run --name squid -p 3128:3128 --rm -d \
 -v /path/to/squid.conf:/etc/squid/squid.conf \
anticaptcha/squid

또 다른 방법은 소스에서 빌드하는 것입니다.

yum -y install make gcc gcc-c++ libtool wget httpd-tools
wget http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.3.tar.gz
tar -zxf squid-3.2.3.tar.gz
cd squid-3.2.3
./configure
make
make install

환경 설정 파일 예시:

#configure the port number
http_port 9191

cache_mem 5 MB
cache_dir ufs /usr/local/squid/var/cache 300 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
pid_filename /usr/local/squid/var/logs/squid.pid



auth_param basic program /usr/local/squid/libexec/basic_ncsa_auth /usr/local/squid/etc/squid_users

auth_param basic children 5
auth_param basic realm enter_your_pass
auth_param basic credentialsttl 2 hours

error_directory /usr/local/squid/share/errors/


acl SSL_ports port 443
acl Safe_ports port 80 8080 3128 # http
acl Safe_ports port 443# https
acl CONNECT method CONNECT
acl MYUSERS proxy_auth REQUIRED
acl to_ipv6 dst ipv6


http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow net


#allow only athorized users
http_access allow MYUSERS
http_reply_access allow all
icp_access deny all
miss_access allow all


#squid will run under nobody user
cache_effective_user nobody
cache_effective_group nobody
coredump_dir /usr/local/squid/var/cache


## making it anonymous
forwarded_for transparent
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_header_access Cache-Control deny all

SQUID에서 별도의 파일에 로그인과 비밀번호를 보관합니다. 저희의 경우에는 "/usr/local/squid/etc/squid_users"에 저장합니다. 파일을 관리하시려면 "htpasswd" 툴을 이용하세요:

htpasswd -c /usr/local/squid/etc/squid_users mylogin

환경 설정이 완료된 이후에, SQUID의 디렉토리 허가 권한을 변경하고 데몬으로 실행하세요:

chown -R nobody:nobody /usr/local/squid/share /usr/local/squid/var
/usr/local/squid/sbin/squid -z /usr/local/squid/etc/squid.conf
/usr/local/squid/sbin/squid -f /usr/local/squid/etc/squid.conf

프록시가 실행되고 있고 인터넷 연결을 수락하는지 확인하세요:

netstat -lenp|grep squid

curl -x IP_HERE:3128 -U mylogin:mypassword http://antigate.com/iptest.php