스퀴드(Squid)는 캐싱(caching) 및 전방향 HTTP 웹 프록시입니다. 그것은 반복된 요청을 캐싱, 네트워크 자원을 공유하는 사람들의 그룹에 대한 웹, DNS 및 기타 컴퓨터 네트워크 조회를 캐싱함으로써 웹 서버의 속도를 높이는 것, 그리고 트래픽을 필터링함으로써 보안 지원을 포함하는, 다양한 용도로 사용됩니다. 비록 HTTP와 FTP에 대해 주로 사용될지라도, 스퀴드는 인터넷 고퍼, SSL, TLS 및 HTTPS를 비롯한 여러 다른 프로토콜에 대한 제한된 지원을 포함합니다. 스퀴드는 SOCKS 프로토콜을 지원하지 않습니다.
스퀴드는 원래 유닉스-계열 시스템에서 데몬(daemon)으로 실행되도록 설계되었습니다. 윈도우 포트는 2.7버전까지 유지되었습니다. 윈도우에서 사용할 수 있는 새 버전은 Cygwin 환경을 사용합니다. 스퀴드는 GNU 일반 공중 사용 허가서 아래에서 공개된 자유 소프트웨어입니다.
Installation
터미널 프롬프트에서, 스퀴드 서버를 설치하기 위하여 다음의 명령을 입력합니다:
- sudo apt install squid
Configuration
자신의 컴퓨터에서 동작하는 프록시로는 기본 설정으로도 동작을 합니다.
- sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.dist
- sudo chmod a-w /etc/squid/squid.conf.dist
- sudo sed -i "/^#/d;/^ *$/d" /etc/squid/squid.conf
만약 다른 컴이나 폰에서 접근하기 위해서는 프록시 서버의 이름을 추가해 주어야 합니다. 또한 방화벽에서 해당되는 포트를 열어주어야 합니다. /etc/squid/squid.conf에 씁니다.
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
acl 호스트_이름 src ip_주소/netmask
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access allow 호스트_이름
http_access deny all
http_port 3128
...
- sudo ufw allow 3128
- sudo ufw allow 3129
For MediaWiki
mw:Manual:Squid caching에 따라 다음을 추가해야 합니다. /etc/squid/squid.conf에 씁니다.
# for mediawiki
cache_peer 127.0.0.1 parent 80 3130 default
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
# Allow cache purge requests from MediaWiki/localhost only
acl purge method PURGE
http_access allow purge localhost
http_access deny purge
http_access allow localhost
http_access deny all
http_port 3128
http_ports 3129 tls-cert=/etc/letsencrypt/live/dawoum.duckdns.org/fullchain.pem tls-key=/etc/letsencrypt/live/dawoum.duckdns.org/privkey.pem
coredump_dir /var/spool/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320
shutdown_lifetime 10 seconds
Boot services
Systemd
부팅 시에 실행하기 위해서는:
- sudo systemctl enable squid
지금 바로 실행하기 위해서는:
- sudo systemctl start squid
Browser configuration
Firefox
파이어폭스 설정은 Preferences->Advanced에서 Network 부분에 Connection의 Settings를 누릅니다. Manual proxy configuration에서 localhost port 3128 또는 127.0.0.1 port 3128 값을 입력하신 후에 아래쪽의 Use this proxy server for all protocols를 체크해 줍니다.
Google Chrome
크롬 설정은 Settings->show advanced settings에서 Network에서 Change proxy settings...을 누릅니다.
Troubleshooting
서비스 종료 시간
시스템 종료 시에 squid 종료에 30초가 소요됩니다. 이를 줄이는 방법은 설정에 다음을 추가하는 것입니다.
shutdown_lifetime 10 seconds
또한, 이 문서에 따르면, 시작 스크립트를 수정해 볼 수도 있다고 합니다. /etc/init.d/squid에 씁니다.
112 if test -n "$PID" && kill -0 $PID 2>/dev/null
113 then
114 log_action_begin_msg " Waiting"
115 cnt=0
116 while kill -0 $PID 2>/dev/null
117 do
118 cnt=`expr $cnt + 1`
119 if [ $cnt -gt 24 ]
120 then
121 log_action_end_msg 1
116 번째 줄을 다음과 같이 바꿉니다.
while kill -15 $PID 2>/dev/null