Linux

설치

  1. 설치해야 할 패키지:
    1. openssl : yum -y install openssl
    2. openssl-dev  (or libssl-dev)
    3. gcc
    4. make
    5. perl
    6. vim (다른 편집기도 사용 가능)
  2. squid 3.0(http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE19.tar.gz) 압축 풀기
    wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE19.tar.gz
    tar zxvf squid-3.0.STABLE19.tar.gz
  3. cd squid-3.0.STABLE19
  4. 64비트 OS : export CFLAGS="-O2 -pipe -m64 -march=core2 -fomit-frame-pointer -s"
    32비트 OS : export CFLAGS="-O2 -pipe -m32 -fomit-frame-pointer -s"
  5. 64비트 OS : export CXXFLAGS="-O2 -pipe -m64 -march=core2 -fomit-frame-pointer -s"
    32비트 OS : export CXXFLAGS="-O2 -pipe -m32 -fomit-frame-pointer -s"
  6. 64비트 OS : export LDFLAGS="-m64 -s -Wl,-O1"
    32비트 OS : export LDFLAGS="-m32 -s -Wl,-O1"
  7. ./configure -prefix=/usr/local/squid --with-pthreads --enable-storeio=ufs,aufs --enable-removal-policies=lru,heap --enable-ssl --with-large-files
  8. make 실행
    warning 등으로 인한 실패시 make SQUID_CFLAGS=-O2 SQUID_CXXFLAGS=-O2 AM_CFLAGS=O2 AM_CXXFLAGS=-O2
  9. 루트(root) 사용자 권한으로 실행 : make install
  10. /usr/local/squid 쓰기 가능한지 체크 

구성

  1. /usr/local/squid/etc/squid.conf 파일 내용 아래와 같이 대체
    (참조 : http://www.squid-cache.org/Versions/v3/3.0/cfgman/)
  2. cache_store_log none
    cache_peer <jazz.server.host.address> parent <jazz.server.host.port> 0 no-query originserver name=httpsAccel ssl
    (앞줄 계속) login=PROXYPASS sslflags=DONT_VERIFY_PEER
    cache_peer_access httpsAccel allow all
    coredump_dir /usr/local/squid/var/cache
    http_access allow all
    https_port <proxy.port> cert=/usr/local/squid/etc/server.pem accel key=/usr/local/squid/etc/privkey.pem vhost
    refresh_pattern .              0       20%     4320
    cache_replacement_policy heap GDSF
    memory_replacement_policy heap GDSF
    cache_dir aufs /usr/local/squid/var/cache <disk.cache.size> 256 256

    cache_mem <memory.cache> MB
    cachemgr_passwd disable all
    maximum_object_size 1048576 KB
    maximum_object_size_in_memory 16384 KB
    buffered_logs on
    visible_hostname <proxy.host.address>

    1. Replace all references of <jazz.server.host.address> with the hostname of the server you wish to proxy.
    2. Replace all references of <jazz.server.host.port> with the port name that your jazz server listens upon.
    3. Replace all references of <proxy.host.address> with the hostname of your proxy machine.
    4. Replace all references of <proxy.port> with the port of your proxy machine.
    5. Replace all references of <memory.cache> with the amount of RAM that you want to allocate to squid's caching.  This must be less than the available memory on the machine.
    6. Replace all references of <disk.cache.size> in MBytes with the amount of diskspace you want ot allocate to squid.  This must be less than the available disk space in "/usr/local/squid/var/cache".  
    <예>
    cache_store_log none
    cache_peer x.x.x.x parent 9443 0 no-query originserver name=httpsAccel ssl login=PROXYPASS sslflags=DONT_VERIFY_PEER
    cache_peer_access httpsAccel allow all
    coredump_dir /usr/local/squid/var/cache
    http_access allow all
    https_port 9443 cert=/usr/local/squid/etc/server.pem accel key=/usr/local/squid/etc/privkey.pem vhost
    refresh_pattern . 0 20% 4320
    cache_replacement_policy heap GDSF
    memory_replacement_policy heap GDSF
    cache_dir aufs /home/SquidCache 131072 256 256

    cache_swap_low 70
    cache_swap_high 97
    cache_mem 4096 MB
    cachemgr_passwd disable all
    maximum_object_size 1048576 KB
    maximum_object_size_in_memory 16384 KB
    buffered_logs on
    visible_hostname x.x.x.x
  3. server.pemprivkey.pem 파일을 /usr/local/squid/etc 아래로 복사
    • 인증서 만들기
      1. openssl req -new -keyform PEM -x509 -out server.pem
      2. openssl rsa -in privkey.pem -out privkey.pem.new
      3. cp privkey.pem.new privkey.pem
      4. cp server.pem /usr/local/squid/etc/
      5. cp privkey.pem /usr/local/squid/etc/
  4. cd /usr/local/squid/sbin
  5. 캐시 디렉토리(/usr/local/squid/var/cache) 구조화/초기화 실행 : ./squid -z
  6. 프락시서버 데몬 실헹 : ./squid
If things are not working properly, check the var/logs/cache.log for errors
you will see TCP_HIT and TCP_MISS logging in the access.log which will indicate whether or not the cache is being hit