
Squid Proxy 란?
오픈소스 프록시 서버이다.
웹 서버의 캐싱 용도로 사용하거나, 특정 IP 및 도메인을 차단, IP 우회 등 다양한 기능을 제공한다.
Squid Proxy 설치
설치방법
dnf install -y squid
설치 후 /etc/squid/squid.conf 에서 squid proxy 설정파일을 확인할 수 있다.
squid proxy 기본설정은 아래와 같다.
/etc/squid/squid.conf
  1 #
  2 # Recommended minimum configuration:
  3 #
  4
  5 # Example rule allowing access from your local networks.
  6 # Adapt to list your (internal) IP networks from where browsing
  7 # should be allowed
  8 acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
  9 acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
 10 acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
 11 acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
 12 acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
 13 acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
 14 acl localnet src fc00::/7           # RFC 4193 local private network range
 15 acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
 16
 17 acl SSL_ports port 443
 18 acl Safe_ports port 80      # http
 19 acl Safe_ports port 21      # ftp
 20 acl Safe_ports port 443     # https
 21 acl Safe_ports port 210     # wais
 22 acl Safe_ports port 1025-65535  # unregistered ports
 23 acl Safe_ports port 280     # http-mgmt
 24 acl Safe_ports port 488     # gss-http
 25 acl Safe_ports port 591     # filemaker
 26 acl Safe_ports port 777     # multiling http
 27 acl CONNECT method CONNECT
 28
 29 #
 30 # Recommended minimum Access Permission configuration:
 31 #
 32 # Deny requests to certain unsafe ports
 33 http_access deny !Safe_ports
 34
 35 # Deny CONNECT to other than secure SSL ports
 36 http_access deny CONNECT !SSL_ports
 37
 38 # Only allow cachemgr access from localhost
 39 http_access allow localhost manager
 40 http_access deny manager
 41
 42 # We strongly recommend the following be uncommented to protect innocent
 43 # web applications running on the proxy server who think the only
 44 # one who can access services on "localhost" is a local user
 45 #http_access deny to_localhost
 46
 47 #
 48 # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
 49 #
 50
 51 # Example rule allowing access from your local networks.
 52 # Adapt localnet in the ACL section to list your (internal) IP networks
 53 # from where browsing should be allowed
 54 http_access allow localnet
 55 http_access allow localhost
 56
 57 # And finally deny all other access to this proxy
 58 http_access deny all
 59
 60 # Squid normally listens to port 3128
 61 http_port 3128
 62
 63 # Uncomment and adjust the following to add a disk cache directory.
 64 #cache_dir ufs /var/spool/squid 100 16 256
 65
 66 # Leave coredumps in the first cache dir
 67 coredump_dir /var/spool/squid
 68
 69 #
 70 # Add any of your own refresh_pattern entries above these.
 71 #
 72 refresh_pattern ^ftp:       1440    20% 10080
 73 refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
 74 refresh_pattern .       0   20% 4320
Squid Proxy 설정
http_access
: 정의된 ACL 규칙에 대하여 접근을 Allow/Deny 하는 설정이다.
32 # Deny requests to certain unsafe ports
33 http_access deny !Safe_ports
34
35 # Deny CONNECT to other than secure SSL ports
36 http_access deny CONNECT !SSL_ports
39 http_access allow localhost manager
40 http_access deny manager
54 http_access allow localnet
55 http_access allow localhost
58 http_access deny all
ACL 은 아래 예제와 같이 설정할 수 있다.
  5 # Example rule allowing access from your local networks.
  6 # Adapt to list your (internal) IP networks from where browsing
  7 # should be allowed
  8 acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
  9 acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
 10 acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
 11 acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
 12 acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
 13 acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
 14 acl localnet src fc00::/7           # RFC 4193 local private network range
 15 acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
 16
 17 acl SSL_ports port 443
 18 acl Safe_ports port 80      # http
 19 acl Safe_ports port 21      # ftp
 20 acl Safe_ports port 443     # https
 21 acl Safe_ports port 210     # wais
 22 acl Safe_ports port 1025-65535  # unregistered ports
 23 acl Safe_ports port 280     # http-mgmt
 24 acl Safe_ports port 488     # gss-http
 25 acl Safe_ports port 591     # filemaker
 26 acl Safe_ports port 777     # multiling http
 27 acl CONNECT method CONNECT
Safe_ports 규칙 외 액세스 요청을 차단한다.
SSL_ports 규칙 외 CONNECT 메소드 연결 요청은 차단한다.
32 # Deny requests to certain unsafe ports
33 http_access deny !Safe_ports
34
35 # Deny CONNECT to other than secure SSL ports
36 http_access deny CONNECT !SSL_ports
모든 액세스 요청 허용 설정
http_access allow all
특정 네트워크 대역만 허용
acl members src 192.168.3.0/255.255.255.0
http_access allow members
http_access deny all
http_port
: squid proxy 의 포트를 설정한다. (기본 3128)
60 # Squid normally listens to port 3128
61 http_port 3128
cache_mgr, cache_effective_user, cache_effective_group
cache_mgr 은 관리자 이메일이다.
cache_effective_user 는 squid proxy 프로세스를 실행할 때 사용하는 시스템 계정이며 마찬가지로
cache_effective_group 은 프로세스를 실행할 때 사용하는 시스템 그룹이다.
cache_mgr admin@example.com
cache_effective_user squid
cache_effective_group squid
coredump_dir
: Squid Proxy 가 비정상적으로 종료될 시 생성되는 코어 덤프 파일 위치 지정
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
캐시 설정방법
cache_mem 8 MB
maximum_object_size 4096 KB
cache_dir ufs /usr/local/squid/cache 100 16 256
cache_mem 8 MB 
 - 스퀴드 서버에서 사용하는 캐시 사이즈를 설정한다.
maximum_object_size 4096 KB 
 - 캐시 서버에 저장될 수 있는 객체 즉, 파일의 크기를 제한하는 옵션이다.
cache_dir ufs /usr/local/squid/cache 100 16 256 
 - 캐시가 저장될 경로를 지정해주는 항목으로 크기와 생성될 하위 1차 및 2차 디렉토리의 수를 지정한다.  
 - 현재 설정은 /usr/local/squid/cache 디렉토리에 캐시데이터들이 최대 100MB 까지 저장될 수 있고, 캐시가 저장될 1차 디렉토리는 16 개로 설정하고 그 밑에 2차 디렉토리 수를 256 개로 설정한다.
로그 설정방법
cache_access_log /usr/local/squid/logs/access.log
cache_log /usr/local/squid/logs/cache.log
cache_access_log /usr/local/squid/logs/access.log 
 - 접근로그를 기록하는 파일을 설정한다.
cache_log /usr/local/squid/logs/cache.log 
 - 캐쉬설정에 관한 로그를 기록하는 파일을 설정한다.
설치 확인
systemctl enable --now squid
systemctl status squid

'Server > Rocky Linux' 카테고리의 다른 글
| [Proxy] Traefik 이란? (0) | 2025.09.14 | 
|---|---|
| [NAS] Linux NAS 서버 구축 (0) | 2025.09.09 | 
| [Proxy] Squid Proxy Health Check 설정 (1) | 2025.05.02 | 
| [Proxy] Squid Proxy 6.12 수동설치 (Redhat 8.6) (0) | 2025.04.23 | 
| [Linux] 기본 환경구성 (Rocky 8.x, 9.x) (0) | 2025.03.28 | 
