본문 바로가기
+ Security

[Squid] 스퀴드 프록시(프락시) 설치 및 보안 설정(Installation and Security Setting of Squid Proxy)

by :: Teacher :: 2017. 6. 17.
728x90
반응형

프록시(프락시)로 많이 사용되고 있는 Squid Proxy에 대해서 설치 및 보안설정 방법을 알아보도록 하자. 

1. Install

1.1 yum을 통한 설치

  • CentOS 에서 yum을 통해서 간단하게 설치해 보도록 하자.

$ yum install squid.x86_64

Loaded plugins: fastestmirror, versionlock

... 이하 생략 ...

Dependencies Resolved

===================================================================================================

 Package    Arch    Version                Repository    Size

===================================================================================================

Installing:

 squid    x86_64    7:3.5.20-2.el7_3.3    update    3.1 M

Installing for dependencies:

 libecap    x86_64    1.0.0-1.el7    base    21 k

 libtool-ltdl    x86_64    2.4.2-22.el7_3    update    49 k

 perl-DBI    x86_64    1.627-4.el7    base    802 k

 perl-Net-Daemon    noarch    0.48-5.el7    base    51 k

 perl-PlRPC    noarch    0.2020-14.el7    base    36 k

 squid-migration-script    x86_64    7:3.5.20-2.el7_3.3    update    48 k

Transaction Summary

===================================================================================================

Install  1 Package (+6 Dependent packages)

Total download size: 4.0 M

Installed size: 12 M

Is this ok [y/d/N]: y

Downloading packages:

... 이하 생략 ...

Complete!

1.2 소스 컴파일 설치

  • Yum을 이용해 설치하는경우 현재 나온 최신 버전(Verison)이 적용이 되지 않는 경우가 있다. 이럴때 소스를 받아 컴파일(Complie) 하여 설치 해보도록 하자.

$ wget http://www.squid-cache.org/Versions/v3/3.5/squid-3.5.20.tar.gz

$ tar xvfz squid-3.5.20.tar.gz

$ cd squid-3.5.20

$ ./configure --prefix=설치위치

$ make

$ make install

 


 

소스 다운로드 URL 

- http://www.squid-cache.org/

 

728x90

 

2. 보안 설정

2.1 Version 정보 노출 제거

  • Header(헤더) 나 Error Page(에러 페이지)를 통해서 현재 사용되고 있는 스퀴드의 버전, 호스트정보를 알수 있다. 

▶︎ Header 정보를 통한 Version 노출

$ curl -i http://127.0.0.1:3128

HTTP/1.1 400 Bad Request

Server: squid/3.5.20

X-Cache: MISS from sec-proxy-test1

X-Cache-Lookup: NONE from sec-proxy-test1:3128

Via: 1.1 sec-proxy-test1 (squid/3.5.20)

... 이하 생략 ....

 

▶︎ Error page Footer를 통한 Version 노출

... 이하 생략 ...

<hr>

<div id="footer">

<p>Generated Mon, 12 Jun 2017 04:00:51 GMT by proxy-test1 (squid/3.5.20)</p>

<!-- ERR_INVALID_URL -->

</div>

</body></html>



 

▶︎ 설정 방법

$ vi /etc/squid/squid.conf

 

# via version off

via off

 

# Server version off

reply_header_access Server deny all

httpd_suppress_version_string on

 

# Cache version off

reply_header_access X-Cache deny all

reply_header_access X-Cache-Lookup deny all

 


 

▶︎ 참고 설명

via :  Via 헤더를 통한 요청 / 응답이 없을 경우 기능 제한 합니다.

- http://www.squid-cache.org/Doc/config/via/

 

Server version : 응답헤더 & Error Page에 버전정보가 노출되지 않도록 설정 합니다.

- http://www.squid-cache.org/Doc/config/reply_header_access/

- http://www.squid-cache.org/Doc/config/httpd_suppress_version_string/

 

Cache version : X-Cache & X-Cache-Lookup에 버전정보가 노출 되지 않도록 설정 합니다.

- http://www.squid-cache.org/Doc/config/reply_header_access/

 

2.2 X-Forwarded-For 설정

$ vi /etc/squid/squid.conf
 
# X-Forwarded-For off
forwarded_for delete 
 
 

 

▶︎ 예제(웹 서비스 Log)
$ tail -f access_log
 
적용 이전
10.10.10.10 111.111.111.111 - - [09/Jun/2017:17:38:45 +0900] "GET /1.html HTTP/1.1" 200 851 "-" "curl/7.43.0"
 
... 이하 생략 ...
 
적용 이후
- 111.111.111.111 - - [09/Jun/2017:17:50:21 +0900] "GET /1.html HTTP/1.1" 200 851 "-" "curl/7.43.0"
 

 

▶︎ 참고 설명

Proxy를 사용한 호스트IP 정보를 차단하기 위해 설정 합니다.

기본 설정값은 On 입니다.

- http://www.squid-cache.org/Doc/config/forwarded_for/

2.3 Log 설정

▶︎ LogFormat 설정
$ vi /etc/squid/squid.conf
 
logformat customformat %{%Y/%m/%d %H:%M:%S}tl %>a %Ss/%03>Hs:%Sh "%rm %ru HTTP/%rv" %>Hs %<st "%{User-Agent}>h" "%{Referer}>h"
access_log /var/log/squid/access.log customformat
 

 

▶︎ 예제(Squid Log)

$ tail -f access.log
적용 이전
1496997096.856      3 10.10.10.10 TCP_MISS/200 1077 GET http://test.test.com/2.html - HIER_DIRECT/10.198.8.232 text/html
 
... 이하 생략 ...
 
적용 이후
2017/06/09 17:35:38 10.10.10.10 TCP_MISS/200:HIER_DIRECT "GET http://test.test.com/3.html HTTP/1.1" 200 1003 "curl/7.43.0" "-"
 

 

▶︎ Logrotate 설정

- 설정파일에서 Logrotate 기간 과 Log 삭제 기간을 변경 합니다.
- weekly -> daily 
- rotate 5 -> rotate 90
 
$ vi /etc/logrotate.d/squid
 
/var/log/squid/*.log {
    daily                    
    rotate 90       
    compress
    notifempty
    missingok
    nocreate
    sharedscripts
    postrotate
      /usr/sbin/squid -k rotate 2>/dev/null
      sleep 1
    endscript
 

 

▶︎ 참고 설명

Log 파일 생성시 정확하고 보기 편한 형태로 LogFormat을 설정 합니다.
- http://www.squid-cache.org/Doc/config/logformat/

 

728x90
반응형

댓글


loading