오늘: 11|어제: 18|전체: 234,159|회원: 118 (+0)|문서: 56,040 (+0)|댓글: 8,019 (+0)|첨부파일: 1,389 (+0)


조회 수 2280 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
Extra Form

자신의 웹사이트.htaccess를 수정해서 웹 사이트 퍼포먼스 향상 및 트래픽 절감 효과를 얻을수 있는 팁입니다


- .htaccess 파일은 기본 숨김 파일이므로 ftp 프로그램에서 숨김파일 보기 옵션을 키셔야 볼 수 있고

   기본적으로 루트에 있습니다(index.php 파일 있는곳, 모듈폴더와 레이아웃폴더 들이 있는곳 있죠? 그폴더입니다)


- 웹서버 환경설정 및 버전. 그리고 아파치모듈 설치유무에 따라 몇가지 옵션은 작동하지 않을 수 있습니다


- 작업전에 반드시 .htaccess 파일을 백업하고 언제든지 원래 상태로 돌릴수 있는 지식을 가진 상태에서 작업해주세요


- .htaccess파일에 한글이 입력되거나 하면 바로 오류를 뱉으니 놀라지마시고 원래상태로 돌려주시면 됩니다


1.Database 정보파일 (./files/config/db.config.php) 보호

자신의웹사이트주소/files/config/db.config.php 이렇게 접속해 보시면 내용은 나오지 않지만 접속이 되실겁니다

  아래 옵션을 적용하시면 해당 파일로 접근시 서버차원에서 차단시켜버립니다

    (해당 파일에는 db에 접속시 필요한 정보가 들어있습니다)

Database 정보파일 (./files/config/db.config.php) 보호
1
2
3
4
5
#Option 01
<files db.config.php>
order allow,deny
deny from all
</files>


2. 첨부파일 폴더 (./files/attach) 보호

이번 팁은 ./files/attach 경로에 파일명 .htaccess 로 만드신후 아래 소스를 적으시고 넣으시면됩니다

적용 후엔 첨부파일 폴더에 악의적으로 PHP코드가 심어진 파일이 업로드 되더라도 PHP로 실행하지 않습니다

php를 사용하지 않는다는 내용의 소스이므로 첨부파일 폴더가 아닌곳에 넣으시면 php가 작동하지 않습니다

+

설명이 이해가 안되시는 분들은 .htaccess 이 파일을 .htaccess라는 이름으로 ./files/attach 경로에 넣으시면됩니다

넣기 전과 넣은 후를 테스트 해보시려면 phpver.php 이 파일을 ./files/attach 에 업로드 하고 웹에서 접속하고

아래 팁 적용 후 다시 접속하시면 php파일이 실행되지않고 다운로드창이 뜨는걸 확인하실수 있습니다

첨부파일 폴더 (./files/attach) 보호
1
2
3
4
5
6
7
#Option 02
<IfModule mod_php5.c>
  php_value engine off
</IfModule>
<IfModule mod_php4.c>
  php_value engine off
</IfModule>


3. .htaccess 파일 (./.htaccess) 보호

웹 서버 유저 (호스팅사용자) 별로 일부 아파치 환경설정을 바꿀 수 있는 .htaccess 파일을 보호합니다 적용 후엔

.htaccess 파일을 서버차원에서 보호합니다 아파치 환경설정을 변경해 악의적인 목적을 달성하는 해킹을 예방합니다

.htaccess 파일 (./.htaccess) 보호
1
2
3
4
5
#Option 03
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
</files>


4. 웹 서버의 에러 페이지 변경

404 Not found(파일없음),403 Forbidden(권한없음),500 Internal Server(프로그램오류) 등의 에러 발생시 원하는 페이지를

띄울수 있습니다 적용 후 자신의웹사이트주소/가나다라 같이 없는 페이지를 입력하시면 적용된걸 보실수 있습니다

웹 서버의 에러 페이지 변경
1
2
3
4
#Option 04
ErrorDocument 404 http://www.naver.com/
ErrorDocument 403 http://www.naver.com/
ErrorDocument 500 http://www.naver.com/


5. 홈페이지 주소에 무조건 www 붙이기

홈페이지 접속시 www를 붙이지 않고 접속해도 무조건 www를 붙여주는 기능입니다

이건 애드온으로도 많이 나와있는데 개인적으로 애드온을 최소화 하는 편이라 저는 이렇게 적용시켰습니다

홈페이지 주소에서 WWW 붙이기
1
2
3
4
5
6
7
#Option 05
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>


6. 이미지 파일 무단링크 방지 (jpg,jpeg,png,gif,bmp)

자신의 서버에 있는 이미지 파일을 다른 홈페이지에서 http:// 방식으로 링크하는 것을 방지합니다

트래픽 절약에 상당히 효과가 있지만, 홈페이지 이용회원들의 반발이 있을 수도 있으니 검토가 필요합니다

아래 소스에 naver 라고 적힌곳에 자신의 주소를 적어주세요

이미지 파일 무단링크 방지 (jpg,jpeg,png,gif,bmp)
1
2
3
4
5
6
7
#Option 06
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?www.naver.com.*$ [NC]
RewriteRule \.(jpg|jpeg|png|gif|bmp)$ _ [NC,R,L]
</IfModule>


7. 데이터 파일 무단링크 방지 (pdf,zip,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)

자신의 서버에 있는 데이터 파일을 다른 홈페이지에서 http:// 방식으로 링크하는 것을 방지합니다

트래픽 절약에 상당히 효과가 있지만, 홈페이지 이용회원들의 반발이 있을 수도 있으니 검토가 필요합니다

아래 소스에 naver 라고 적힌곳에 자신의 주소를 적어주세요

데이터 파일 무단링크 방지 (pdf,zip,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)
1
2
3
4
5
6
7
#Option 07
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?www.naver.com.*$ [NC]
RewriteRule \.(pdf|zip|hwp|doc|docx|ppt|pptx|pps|ppsx|xls|xlsx)$ _ [NC,R,L]
</IfModule>


8. 최적 CACHE 설정 - 트래픽 대폭 감소

브라우저 캐시 관련 파일 종류별로 최적 만기일을 설정합니다 설정이 없을 경우 보통 1주일이 지나면 새로 다운로드 받습니다

파일 종류별로 캐시 만기일을 최적 설정해 놓을 경우 약 1개월 후 부터는 웹 사이트의 재 방문율이 높을경우

평균 트래픽이 20%이상 감소합니다

최적 CACHE 설정 - 트래픽 대폭 감소
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Option 08
<IfModule mod_expires.c>
ExpiresActive on
 
ExpiresDefault                          "access plus 1 month"
 
ExpiresByType text/cache-manifest       "access plus 0 seconds"
ExpiresByType text/html                 "access plus 0 seconds"
ExpiresByType text/xml                  "access plus 0 seconds"
ExpiresByType application/xml           "access plus 0 seconds"
ExpiresByType application/json          "access plus 0 seconds"
 
ExpiresByType application/rss+xml       "access plus 3 hour"
ExpiresByType application/atom+xml      "access plus 3 hour"
 
ExpiresByType image/gif                 "access plus 1 month"
ExpiresByType image/png                 "access plus 1 month"
ExpiresByType image/jpg                 "access plus 1 month"
ExpiresByType image/jpeg                "access plus 1 month"
   
ExpiresByType video/ogg                 "access plus 2 month"
ExpiresByType audio/ogg                 "access plus 2 month"
ExpiresByType video/mp4                 "access plus 2 month"
ExpiresByType video/webm                "access plus 2 month"
   
ExpiresByType text/x-component          "access plus 1 year"
ExpiresByType application/x-font-ttf    "access plus 1 year"
ExpiresByType font/opentype             "access plus 1 year"
ExpiresByType application/x-font-woff   "access plus 1 year"
ExpiresByType image/svg+xml             "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType text/css                  "access plus 1 year"
ExpiresByType application/javascript    "access plus 1 year"
ExpiresByType image/x-icon              "access plus 1 year"
</IfModule>


9. 악성 봇 (bots) 차단

홈페이지 전체를 통채로 긁어가는 용도의 어플이 있습니다 이와 비슷한 어플들을 악성 봇으로 판단하여 차단합니다

이런 어플을 사용하는 사람들은 나름의 이유가 있겠습니다만, 홈페이지 운영에 있어서는 트래픽은 곧 돈입니다

악성 봇 (bots) 차단
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#Option 09
<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
</IfModule> 

10. 디렉토리 리스팅 방지

웹서버의 특정 폴더에 index 파일이 없을 경우 디렉토리 전체를 리스트하지 않게 합니다.

대부분의 서버에 이미 설정되어 있습니다 단, 외국 일부 웹호스팅 업체나 개인적으로 서버 세팅을 하셨을 경우

설정이 미처 되어 있지 않을 수 있습니다

디렉토리 리스팅 방지
1
2
#Option 10
Options All -Indexes


11. 일부 데이터 파일을 브라우저에서 바로 열리는 경우없이 무조건 다운로드

     (pdf,csv,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)

위 파일 확장자를 가진 파일은 윈도우 설정에 따라 브라우저에서 바로 열리기도 합니다

무조건 다운로드 되도록 하는 설정이나, 아쉽게도 일부 서버 환경에서만 적용됩니다.

일부 데이터 파일을 브라우저에서 바로 열리는 경우없이 무조건 다운로드 (pdf,csv,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)
1
2
3
4
5
6
7
8
9
10
11
12
#Option 11
AddType application/octet-stream .csv
AddType application/octet-stream .xls
AddType application/octet-stream .xlsx
AddType application/octet-stream .doc
AddType application/octet-stream .docx
AddType application/octet-stream .hwp
AddType application/octet-stream .ppt
AddType application/octet-stream .pptx
AddType application/octet-stream .pps
AddType application/octet-stream .ppsx
AddType application/octet-stream .pdf


12. 서버 서명 (Signature) 출력 안함

서버 관련 에러페이지를 보면 하단에 서버 서명 (Signature) 이 출력됩니다

그 서명안에 서버 버전 정보와 호스트명 그리고 포트번호가 나오는데 해커에 의해 악용될 수 있으니 지웁시다

서버 서명 (Signature) 출력 안함
1
2
#Option 12
ServerSignature Off
출처 : http://www.xpressengine.com/tip/22391008

?Who's Luatic™

profile

Luatic Hosting 운영자

Atachment
첨부파일 '1'

List of Articles
글쓴이 분류 제목 조회 수
루아틱 Apache 사이트 복사 방지 .htaccess에 추가하세요 32622
루아틱 Linux 우분투 12.04 LTS Sever 윈도우에서 우분투로 원격 데스크탑(RDP) 사용하기 3 30352
루아틱 Linux Ubuntu 12.04 LTS Java7 설치시 오류 및 오류 해결법 30327
Luatic™ Linux 갤럭시 S3 에 Ubuntu Linux 설치하기 (영문) 3 file 27813
루아틱 Apache Apache 2 prefork 와 worker 차이 23702
루아틱 Etc ftp에서 passive와 active 모드의 차이? 2 22601
Luatic™ PHP 워드 프레스 사용시 piwik 쉽게 연동 하기 file 21817
루아틱 Linux 우분투 10.04 LTS, sendmail 설치 및 설정 3 21127
루아틱 Etc Byte(바이트) 와 bit(비트)의 차이 1 19783
Luatic™ XpressEngine 루아틱 서버 XE사용시 몇가지 팁 file 19375
루아틱 Etc html 색상표 18479
루아틱 Etc 돈한푼 안들이고 내 사이트 만들기 1탄 3 18382
루아틱 MySQL mysql DB 백업과 복구 17609
포인트 Linux 리눅스 특정확장자 하위디렉토리까지 일괄삭제하기 17374
루아틱 Apache 아파치2 에서 mod_cband 사용법 17236
루아틱 PHP SSL 보안서버인증 적용하기 - 웹호스팅 (XE) 17139
루아틱 Windows Windows 2003에서 IIS 6.0 설치(SSL 설정 1) 16767
Luatic™ PHP XE Cache 적용하기 file 16365
루아틱 Linux 우분투 시간 동기화 하기 16061
루아틱 PHP KimsQ RB로 홈페이지+모바일홈피 5분만에 만들기 1 15624
Board Pagination ‹ Prev 1 2 3 4 5 6 Next ›
/ 6

처음