일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- HTTPD
- docker image
- permission
- nmcli
- 랜카드인식불량
- 날짜변경
- tar
- ssh
- 엑셀파일명변경
- chatGPT
- docker network
- 같은폴더
- Kubernetes
- ansible
- lvcreate
- vgcreate
- mount
- pvcreate
- M365필터
- swapon
- firewalld
- vagrant kubernetes
- newbingai
- MSBing
- 리다이렉션
- journalctl
- yum
- 프로세스
- chmod
- docker
- Today
- Total
becool
20210616 (수) dns, web서비스 본문
SSH : 원격접속 ssh ssh-keygen ssh-copy-id scp
DNS : IP주소와 이름주소를 매핑해주는 서비스
FTP : 파일을 원격으로 복사하는 작업 SFTP VSFTP 보안강화
SAMBA : 원격 시스템 간에 디렉터리/장치 등을 공유 (특히, 윈도우os, 프린트 등을 대상으로 할때)
NFS : 원격 시스템 간에 디렉터리 공유, 스토리지
iSCSI : 스토리지(볼륨)를 원격으로 제공
서비스 설정 순서
1. 패키지 설치 (네트워크, 리포지토리 설정등 포함)
2. 서비스 설정 (사용자/파일/스토리지 … + 서비스 설정파일관리 +@SELinux 설정)
3. 서비스 실행 (활성화/재시작)
4. 방화벽 설정
==============================================
DNS 서버 구성
1. DNS 이름 조회 구성 ( bind, bind-utils / zone파일 작성 / named 서비스 / dns )
Nat-network 대역 : 10.0.2.0/24 (server-world.info/en)
IP 주소
10.0.2.10 - DNS서버 (primary)
10.0.2.20 - DNS서버 (secondary)
10.0.2.30 - WEB서버
10.0.2.40 - NFS 서버
DNS 이름
XXX.school.exam.com (dnsschool.exam.com)
2. 간단한 웹서버 구성
3. NFS 서버로 web에서 사용할 컨텐츠 제공
[root@host1 ~]# hostnamectl set-hostname dns.school.exam.com
[root@host1 ~]# hostnamectl
Static hostname: dns.school.exam.com
Icon name: computer-vm
Chassis: vm
Machine ID: 1204c6902547104ebefc4f6f0e09105f
Boot ID: bcd353f19b6046299e4a127fecef4472
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.21.1.el7.x86_64
Architecture: x86-64
[root@host1 ~]# nmcli con mod enp0s3 ipv4.addresses 10.0.2.10/24
[root@host1 ~]# nmcli con mod enp0s3 ipv4.gateway 10.0.2.1
[root@host1 ~]# yum install -y bind bind-utils
[root@host1 ~]# nmcli con mod enp0s3 ipv4.dns 10.0.2.10
[root@host1 ~]# nmcli con mod enp0s3 ipv4.method manual
[root@host1 ~]# nmcli con up enp0s3
etc/named.conf
접근제어 변경 설정 53번포트 dns
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { none; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
allow-transfer { 10.0.2.20; };
zone 부분을 2개 더 복사하는 이유 : 정방향, 역방향(AA -> PTR, 네트워크아이디 빼고 호스트아이디만)
zone 파일을 직접만드는경우 type : master / zone 파일을 읽어오는 경우 : slave
zone "." IN {
type hint;
file "named.ca";
};
zone "school.exam.com" IN {
type master;
file "school.zone";
};
zone "2.0.10.in-addr.arpa" IN { → arpa 역방향시 필요
type master;
file "2.0.10.db";
};
[root@host1 ~]# cat /var/named/named.empty : 샘플 파일
정방향
$TTL 3H
@ IN SOA school.exam.com. root.localhost. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS primary.school.exam.com.
primary A 10.0.2.10
secondary A 10.0.2.20
web A 10.0.2.30
NFS A 10.0.2.40
역방향
$TTL 3H
@ IN SOA school.exam.com. root.localhost. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS school.exam.com.
10 PTR primary.school.exam.com.
20 PTR secondary.school.exam.com.
30 PTR www.school.exam.com.
[root@host1 ~]# named-checkconf → /etc/named.conf 오류가 없으면 아무메세지 없음
[root@host1 ~]# named-checkzone [DOMAIN] [FILE] → zone에 대한 문법체크
[root@host1 ~]# named-checkzone 11.2.0.10.in-addr.arpa /var/named/2.0.11.db → 역방향 테스트는 도메인도 역방향
[root@host1 named]# systemctl enable --now named
[root@host1 named]# host -t A nfs.school.exam.com
NFS.school.exam.com has address 10.0.2.40
[root@host1 named]# host -t A nfs → 정상출력
NFS.school.exam.com has address 10.0.2.40
[root@host1 named]# host -t A web
web.school.exam.com has address 10.0.2.30
[root@host1 named]# host -t A -v web → -v옵션 (상세)
Trying "web.school.exam.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25539
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;web.school.exam.com. IN A
;; ANSWER SECTION:
web.school.exam.com. 10800 IN A 10.0.2.30
;; AUTHORITY SECTION:
school.exam.com. 10800 IN NS primary.school.exam.com.
;; ADDITIONAL SECTION:
primary.school.exam.com. 10800 IN A 10.0.2.10
Received 92 bytes from 10.0.2.10#53 in 0 ms
[root@host1 named]# host -t PTR 10.0.2.10 → 역방향 테스트 (PTR입력, ip 주소 전체 입력)
10.2.0.10.in-addr.arpa domain name pointer primary.school.exam.com.
세컨더리 : zone 파일 구성 필요없으며, masters 에서 불러오는 것으로 설정
/etc/named.conf
zone "school.exam.com" IN {
type slave;
file "slaves/school.zone";
masters { 10.0.2.10; };
};
[root@host2 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search school.exam.com
nameserver 10.0.2.10
nameserver 8.8.8.8
테스트
[root@host2 ~]# host -t A web
web.school.exam.com has address 10.0.2.30
[root@host2 ~]# host -t A secondary.school.exam.com
secondary.school.exam.com has address 10.0.2.20
================
6장 7장 웹서버 17장 WAS 서버
p283 p355 p835
웹서버 웹서비스
- 프로토콜 : http / https(보안강화, SSL, 인증서) 통해 사용자들에게 특정 컨텐츠를 제공해주는 서버
- 클라이언트 도구 : IE(edge), Chrome, firefox 등 …
- HTML 형식, CSS, PHP, Pythone 등 …
- 구성방식 : Apache, nginx, IIS …
- 정적인 페이지 혹은 동적인 페이지를 제공할 수 있다.
Apache 구성
1. 패키지 설치 : httpd(기본), mod_ssl(HTTPS 구성) / webserver (그룹패키지)
2. 서비스 설정 : /etc/httpd/conf/httpd.conf (메인 구성설정파일) - http서비스에서는 굳이 수정할 필요없음
/etc/httpd/conf.d/XXX.conf (추가파일 구성)
/var/www/html/index.html (기본컨텐츠), index.php, index.py루비 등 다양한 기본 컨텐츠 파일사용가능
다른 경로에 컨텐츠 구성 시 , SELinux 컨텍스트 설정 필요 (fcontext)
사용자 홈디렉터리에 구성할 경우 (userdir) → SELinux 부울 값을 설정해야한다.
포트 번호를 80/443 등의 기본포트에서 변경하려면 SELinux 포트 설정 필요
※ 컨텍스트값은 기본디렉터리의 값을 확인 후 동일하게 설정 (ls -dZ /var/www/html/ )
3. 서비스 활성화 : httpd (HTTP/HTTPS 모두)
4. 방화벽 설정 : http, https 두가지
<Apache 가상호스트>
-실제 서버가 하나이지만 여러 컨텐츠를 각각 다른 주소로 제공하는 형식
-하나의 시스템에서 여러 개의 IP주소 혹은 DNS 주소를 사용하는 경우에,
각각의 컨텐츠를 제공하는 방식
<참고파일의 경로>
[root@host2 ~]# ls /usr/share/doc/httpd-2.4.6/
ABOUT_APACHE httpd-languages.conf LICENSE
CHANGES httpd-manual.conf NOTICE
httpd-dav.conf httpd-mpm.conf proxy-html.conf
httpd-default.conf httpd-multilang-errordoc.conf README
httpd-info.conf httpd-vhosts.conf VERSIONING
1. IP기반의 가상호스트 (비용 ↑)
A 시스템
A컨텐츠 ← 10.0.2.10 ← 사용자
B컨텐츠 ← 10.0.2.20 ← 사용자
▶ IP기반의 가상호스트를 설정하는 경우 <VirtualHost xxx.xxx.xxx.xxx : 포트>
2. 이름기반의 가상호스트 (ip는 하나, dns주소는 다수 / 상대적으로 비용 저렴)
B 시스템
A컨텐츠 ← A.exam.com ← 사용자
B컨텐츠 ← B.exam.com ← 사용자
▶ 항상 <VirtualHost * :포트> 이름기반의 가상호스트를 설정하는경우 항상 * 사용
<virtualHost *:80> ServerName AAAA → dns에 등록된 서버네임으로 설정해야함(var/named/xxx.zone 파일) DocumentRoot "/var/www/html2" </virtualhost> <directory "/var/www/html2"> AllowOverride None Require all granted </directory> |
===================
실습
1. DNS 서버 하나만 준비 (마스터서버)
2. WEB서버 하나 준비 (가상호스트 방식)
web1.school.exam.com → Hello World!!
web2.school.exam.com → Goodbye World!!
IP 주소로 접근 → GoodBye World!!
1번 페이지 : /var/www/html2/index.html
2번 페이지 : /srv/www/html/index.html
web1/web2 → 10.0.2.XX 웹서버주소 설정
1. DNS 수정
school.zone 파일에서 주소 추가 (역방향도 해주면 좋음)
web1 A 10.0.2.30
web2 A 10.0.2.30
2. 웹서버 구성
# yum install httpd -y
# vim /etc/httpd/conf.d/00-vhost.conf
<VirtualHost *:80>
ServerName web2.school.exam.com
DocumentRoot "/srv/www/html"
</VirtualHost>
<Directory /srv/www/html>
AllowOverride none
Require all granted
</Directory>
# vim /etc/httpd/conf.d/01-vhost.conf
<VirtualHost *:80>
ServerName web1.school.exam.com
DocumentRoot "/var/www/html2"
</VirtualHost>
<Directory /var/www/html2>
AllowOverride none
Require all granted
</Directory>
semanage fcontext -l |grep www
r:httpd_sys_script_exec
r:httpd_sys_content_t
# ls -Zd /var/www/html2
[root@host1 conf.d]# ls -Zd /var/www/html2/index.html
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html2/index.html
# restorecon -RFv /var/www/
# echo "Hello World!!" > /var/www/html2/index.html
# mkdir -p /srv/www/html
# ls -Zd /srv/www/html
[root@host1 conf.d]# ls -Zd /srv/www/html/index.html
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /srv/www/html/index.html
# restorecon -RFv /srv/www
# echo "GoodBye World!!" > /srv/www/html/index.html
작성 후 named.service / httpd.service 재시작 필요 (systemctl)
[root@host2 ~]# curl web1.school.exam.com
Goodbye World
[root@host2 ~]# curl primary.school.exam.com
Hello World
'linux' 카테고리의 다른 글
20210622 (화) Nginx (0) | 2021.06.22 |
---|---|
20210622 (화) webservice (0) | 2021.06.22 |
20210507(금) (0) | 2021.05.07 |
20210506 (목) (0) | 2021.05.06 |
20210504(화) (0) | 2021.05.04 |