작은숲:위키노트/아파치: 두 판 사이의 차이
잔글 문자열 찾아 바꾸기 - "분류:서버" 문자열을 "분류:위키노트/서버" 문자열로 |
잔글 문자열 찾아 바꾸기 - "<source" 문자열을 "<syntaxhighlight" 문자열로 |
||
| 3번째 줄: | 3번째 줄: | ||
=== Apache에서 사용자 인증 방식 사용 === | === Apache에서 사용자 인증 방식 사용 === | ||
==== 사용자 추가 ==== | ==== 사용자 추가 ==== | ||
< | <syntaxhighlight lang="console"> | ||
$ htpasswd -c /usr/local/apache/passwd/passwords someone | $ htpasswd -c /usr/local/apache/passwd/passwords someone | ||
</source> | </source> | ||
==== Apache 설정 ==== | ==== Apache 설정 ==== | ||
< | <syntaxhighlight lang="apache"> | ||
AuthType Basic | AuthType Basic | ||
AuthName "Restricted Files" | AuthName "Restricted Files" | ||
| 17번째 줄: | 17번째 줄: | ||
== 아파치 서버 설정 == | == 아파치 서버 설정 == | ||
=== 그림 파일 등의 외부 링크 금지 === | === 그림 파일 등의 외부 링크 금지 === | ||
< | <syntaxhighlight lang="apache"> | ||
# for link reject | # for link reject | ||
SetEnvIf Referer "http://(www\.)?mooo.org" link_allow | SetEnvIf Referer "http://(www\.)?mooo.org" link_allow | ||
| 34번째 줄: | 34번째 줄: | ||
</source> | </source> | ||
=== 디렉토리 설정 === | === 디렉토리 설정 === | ||
< | <syntaxhighlight lang="apache"> | ||
<Directory "/home/httpd/html"> | <Directory "/home/httpd/html"> | ||
Options FollowSymLinks | Options FollowSymLinks | ||
| 71번째 줄: | 71번째 줄: | ||
* http://oops.org/?t=lecture&sb=apache&n=2 | * http://oops.org/?t=lecture&sb=apache&n=2 | ||
=== 특정 Agent 접속 거부 등 === | === 특정 Agent 접속 거부 등 === | ||
< | <syntaxhighlight lang="apache"> | ||
# 특정 Agent 접근 거부 | # 특정 Agent 접근 거부 | ||
BrowserMatch "WebZIP" no_access | BrowserMatch "WebZIP" no_access | ||
2021년 3월 28일 (일) 12:52 판
아파치 HTTP 서버(Apache HTTP Server)는 아파치 소프트웨어 재단에서 관리하는 HTTP 서버이다. 범용 운영체제의 대부분을 지원한다.[1]
아파치 서버 활용
Apache에서 사용자 인증 방식 사용
사용자 추가
<syntaxhighlight lang="console"> $ htpasswd -c /usr/local/apache/passwd/passwords someone </source>
Apache 설정
<syntaxhighlight lang="apache"> AuthType Basic AuthName "Restricted Files" AuthUserFile /usr/local/apache/passwd/passwords Require user someone </source>
참고
아파치 서버 설정
그림 파일 등의 외부 링크 금지
<syntaxhighlight lang="apache">
- for link reject
SetEnvIf Referer "http://(www\.)?mooo.org" link_allow
- SetEnvIf Referer ^$ link_allow
<Directory /home/httpd/data> order deny,allow deny from all allow from env=link_allow </Directory>
- <FilesMatch ".(gif|bmp|jpe?g|png|GIF|BMP|JPE?G|PNG)$">
- order deny,allow
- deny from all
- allow from env=link_allow
- ErrorDocument 403 "Cannot Link Image Files"
- </FilesMatch>
</source>
디렉토리 설정
<syntaxhighlight lang="apache"> <Directory "/home/httpd/html"> Options FollowSymLinks AllowOverride None
- 서버로부터 자료를 얻어갈 수 있는 위치를 제어한다.
Order allow,deny Allow from all Deny from env=no_access </Directory> </source>
- Options – 해당 디렉토리의 기본 설정. 아래 설정들을 조합할 수 있다.
- None – 어떤 옵션도 이용할 수 없다.
- All – 지정한 디렉토리에서 모든 명령을 이용할 수 있다.
- Indexes – URL에 지정된 디렉토리에 (
index.html같은) 지정된 파일이 없을 경우 디렉토리의 파일 목록을 보여주는 옵션. - Includes – 서버측의 추가적인 정보를 제공할 수 있게 한다.
- IncludesNoExec – 서버측의 추가적인 정보를 제공할 수 있게 하지만, 어떠한 실행 파일을 실행하는 것을 방지한다.
- FollowSymLinks – 디렉토리 상의 심볼릭 링크를 사용가능하게 한다.
- ExecCGI – CGI 스크립트를 실행할 수 있게 한다.
- MultiViews – All 옵션이 설정되었을 때만 지정된 목록의 multiviews를 허용한다.
- AllowOverride –
.htaccess파일은 서버의 각 디렉토리에 만들어서 각 디렉토리에 대한 접근을 제어하기 위한 것으로 디렉토리에.htaccess파일이 있으면, 서버 전체에 작용하는 설정보다 우선권을 가진다..htaccess파일에 대한 Override에 대한 옵션이다. 가능한 옵션은 다음과 같다.- None –
.htaccess파일을 읽을 수 없게 한다. - All – 모든 지정에 대해 가능하게 한다.
- Options – 규정된 디렉토리 형식을 콘트롤하는 지정의 사용을 허락한다.
- FileInfo – 문서 형식을 제어하는 설정의 사용을 허용한다.
- AuthConfig – 사용자 인증 설정의 사용을 허용한다. 사용자 인증 변수를 사용한다.
- Limit – 호스트 접근을 제어하는 설정을 허용한다.
- None –
- Limit에 관련된 부분을 설정을 한다.
- order – 서버가 접근 제어(access control)를 수행하는 순서를 나타낸다. 여기서는 allow 기능을 먼저 수행하고, deny 기능을 수행하라는 것이다.
- deny, allow – deny 지시자 부터 검사하고 allow 지시자를 검사
- allow, deny – allow 지시자 부터 검사하고 deny 지시자를 검사
- mutual-failure – allow 목록에 없는 모든 호스트에게 접속을 거부
- allow from – 나열되는 주소들에 대한 접근 제어를 가능하게 한다. 사용 가능한 주소는 도메인 네임, 호스트 이름 주소, 호스트 IP 주소, IP 주소의 앞부분 3바이트, 모든 주소에 해당하는
all이 있다. - deny from –
allow from과 반대되는 개념이며, 사용가능한 주소는allow from과 같다. - require – 사용자, 그룹에 대한 접근을 통제할 수 있다.
- order – 서버가 접근 제어(access control)를 수행하는 순서를 나타낸다. 여기서는 allow 기능을 먼저 수행하고, deny 기능을 수행하라는 것이다.
참고
특정 Agent 접속 거부 등
<syntaxhighlight lang="apache">
# 특정 Agent 접근 거부
BrowserMatch "WebZIP" no_access BrowserMatch "Teleport" no_access BrowserMatch "GetRight" no_access BrowserMatch "FlashGet" no_access BrowserMatch "JetCar" no_access BrowserMatch "Go!Zilla" no_access BrowserMatch "Namo" no_access BrowserMatch "FrontPage" no_access BrowserMatch "WebTrack-HTTPP" no_access BrowserMatch "WebSymmetrix" no_access
- 로컬 호스트 접속일 때 로그 남기지 않음
SetEnvIf Remote_Addr "^127.0.0.1$" not_log
- 이미지 파일 자바스크립트 파일 등 남기지 않음.
SetEnvIfNoCase Request_URI "\.(bmp|gif|jpg|jpeg|png|css|js|java)$" not_log
- 엔진 로봇 로그를 남기 않음
BrowserMatchNoCase "ru-robot" not_log a_robot BrowserMatchNoCase "Slurp/si" not_log a_robot BrowserMatchNoCase "Mercator" not_log a_robot BrowserMatchNoCase "Gulliver" not_log a_robot BrowserMatchNoCase "SyncIT/" not_log a_robot BrowserMatchNoCase "FAST-WebCrawler" not_log a_robot BrowserMatchNoCase "Lycos_Spider" not_log a_robot BrowserMatchNoCase "^ia_archive" not_log a_robot BrowserMatchNoCase "^tv" not_log a_robot BrowserMatchNoCase "Scooter" not_log a_robot BrowserMatchNoCase "ZyBorg/" not_log a_robot BrowserMatchNoCase "KIT-Fireball" not_log a_robot BrowserMatchNoCase "Googlebot/" not_log a_robot BrowserMatchNoCase "DIIbot/" not_log a_robot BrowserMatchNoCase "teoma_agent3" not_log a_robot BrowserMatchNoCase "empas_robot" not_log a_robot BrowserMatchNoCase "empas" no_access
- 로그 남기기
CustomLog /usr/local/apache/logs/access_log combined env=!not_log <Directory /home/> Options Indexes FollowSymLinks Includes AllowOverride None Order allow,deny Allow from all Deny from env=no_access </Directory> </source>
같이 보기
참고
- http://geist.co.kr/stories.php?story=03/03/30/3913054
- http://www.oops.org/lecture.php?n=3&sb=apache
- http://www.apache-kr.org/documents/authplus-story.html
- http://kltp.kldp.org/stories.php?story=02/08/13/5922292
각주
각주
| 배포판 | |
|---|---|
| 서버 프로그램 | |
| 시스템 도구 | |
| 시스템 보안 | |
| 시스템 설정 | |
| HOWTO 문서 | |
| 사용자 설정 | |
| 활용 | |
| 명령어 | |