티스토리 뷰
728x90
반응형
13장 웹서버 추가 설정
*Apache Selinux 설정
===================
===================
1.Selinux 확인 # ls -Zd /www1/ drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /www1/ 2.file context db 에 등록 # semanage fcontext -a -t httpd_sys_content_t '/www1(/.*)?' 3.Selinux 재확인/ 변경이 안되어 있음. # ls -Zd /www1/ drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /www1/ 4.file context db 확인 # semanage fcontext -l |grep www1 /www1(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 5. context db 에 있는 적용시킴 [root@server1 conf.d]# restorecon -Rvv /www1 restorecon reset /www1 context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0 restorecon reset /www1/html context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0 restorecon reset /www1/html/index.html context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0 |
*정규표현식 설명
================
( : 정규표현식을 묶음 ? : 선행패턴이 0번 또는 1번존재/일치 / : 디렉토리 . : 임의의 한문자 * : 선행패턴이 0번이상 존재 (/.*)? ==> 괄호안의 내용이 있을 수 도 있고 없을 수도 있다. '/www(/.*)?' ==> /www 폴더 밑에 임의의 한문자 이상의 모든것을 의미한다. 하위 디렉토리(/도 한문자로 봄)도 포함된다. |
*CGI 실행기능 사용
===============
샘플 CGI(hostinfo.cgi)
#!/bin/bash echo Content-Type: text-html echo echo The hostname is `hostname`. |
1) 샘플 넣고, virtual host 설정
# mkdir -p /www1/cgi-bin
# mv hostinfo.cgi /www1/cgi-bin
# vi ../conf/httpd.conf (virtualhost 에 추가)
# vi ../conf/httpd.conf (virtualhost 에 추가)
ScriptAlias /cgi-bin/ "/www1/cgi-bin"
|
2) SELINUX 설정확인
# ls -Zd /www1/cgi-bin/
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /www1/cgi-bin/
# ls -Zd /www1/cgi-bin/
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /www1/cgi-bin/
3) file context db에 특정 폴더에 대하여 타입 추가
# semanage fcontext -a -t httpd_sys_script_exec_t '/www1/cgi-bin(/.*)?'
4) file context db 내용을 /www1에 대해서 적용
# restorecon -Rvv /www1
restorecon reset /www1/cgi-bin context unconfined_u:object_r:httpd_sys_content_t:s0->unconfined_u:object_r:httpd_sys_script_exec_t:s0
restorecon reset /www1/cgi-bin context unconfined_u:object_r:httpd_sys_content_t:s0->unconfined_u:object_r:httpd_sys_script_exec_t:s0
5) httpd 재시작
[root@server1 materials]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@server1 materials]# vi /www1/cgi-bin/hostinfo.cgi
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@server1 materials]# vi /www1/cgi-bin/hostinfo.cgi
*사용자 기반 인증 설정
==================
1) File을 이용한 사용자 인증
------------------------
- 사용자 추가
#htpasswd -cm /etc/httpd/.httpasswd bob New Password: redhat Re-type new password: redhat Adding password for user bob #htpasswd -m /etc/httpd/.httpasswd alice New Password: redhat Re-type new password: redhat Adding password for user alice |
- httpd.conf 설정 > virtualHost
<VirtualHost *:80> ServerAdmin root@server1.example.com DocumentRoot /var/www/html <Directory /var/www/html/private> AuthName "Secret Stuff" AuthType basic AuthUserFile /etc/httpd/.httpasswd Require valid-user </Directory> ServerName server1.example.com ServerAlias server1 ErrorLog logs/server1-error_log CustomLog logs/server1-access_log common </VirtualHost> |
2)LDAP 을 이용한 사용자 인증
-------------------------
- httpd.conf 설정> virtualHost
LDAPTrustedGlobalCert CA_BASE64 /etc/httpd/example-ca.crt <VirtualHost *:80> ServerAdmin root@server1.example.com DocumentRoot /var/www/html <Directory /var/www/html/private> AuthName "Secret Stuff" AuthType basic AuthBasicProvider ldap AuthLDAPUrl "ldap://instructor.example.com/dc=example,dc=com" TLS Require valid-user </Directory> ServerName server1.example.com ServerAlias server1 ErrorLog logs/server1-error_log CustomLog logs/server1-access_log common </VirtualHost> |
인증서(공개키)를 가져온다.
# wget ftp://instructor.example.com/pub/example-ca.crt -O /etc/httpd/example-ca.crt
*Apache SELinux 문제해결
========================
1. 포트관련 SELINUX 확인
#semanage port -l |grep http
2.port 를 db에 추가
#semanage port -a -t http_port_t -p tcp 777
*selinux 정책에는 오류 메시지가 로그로 전송되지 않도록 하는 규칙입니다. ==> dontaudit
*만약에 selinux에 문제가 있으면 이것을 off해서 로그를 확인해야한다.
#semanage dontaudit off
*selinux 등록
semanage fcontext -a -t httpd_sys_content_t 'virtual(/.*)?'
restorecon -RFvv /virtual/
*selinux bool 값 확인
#getsebool -a
========================
1. 포트관련 SELINUX 확인
#semanage port -l |grep http
2.port 를 db에 추가
#semanage port -a -t http_port_t -p tcp 777
*selinux 정책에는 오류 메시지가 로그로 전송되지 않도록 하는 규칙입니다. ==> dontaudit
*만약에 selinux에 문제가 있으면 이것을 off해서 로그를 확인해야한다.
#semanage dontaudit off
*selinux 등록
semanage fcontext -a -t httpd_sys_content_t 'virtual(/.*)?'
restorecon -RFvv /virtual/
*selinux bool 값 확인
#getsebool -a
*selinux bool 값 변경
#setsebool -P httpd_enable_cgi off
#semanage boolean -l|grep httpd_enable_cgi
#setsebool -P httpd_enable_cgi off
#semanage boolean -l|grep httpd_enable_cgi
반응형
'IT > RHEL' 카테고리의 다른 글
[RHCE] 캐싱전용 DNS 서버 (0) | 2014.08.17 |
---|---|
[RHCE] SMTP (postfix) 설정 (0) | 2014.08.17 |
[RHCE] 인증키 생성 for SSL (0) | 2014.08.17 |
[RHCE] ISCSI 저장 장치(암호화 luks) (0) | 2014.08.17 |
[RHCE] Bash Scripting (0) | 2014.08.07 |
댓글
250x250
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- RHEL
- 미시사가
- 인터넷
- 우드워킹
- BC주
- BTBS
- basement
- redhat
- certification
- 토론토
- 토론토정착서비스
- 캐나다부동산
- Canada
- 밀튼
- RHCE
- 옥빌
- 온타리오
- cert
- TORONTO
- docker
- 부동산분석
- Red Hat
- Jay
- 정착서비스
- ansible
- 캐나다
- Certificate
- 부모님초청이민
- 벌링턴
- git proGit
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함