수업 15일차 리눅스 Nginx를 이용한 웹서버 접속

유동우·2022년 10월 16일
1

DNS서버 (네임서버 = nameserver = ns)

[호스트][도메인]
www . google.com

[설명]

  • TTL : 데이터가 유지될 수 있는 시간
  • @ : 이 도메인을 기본 도메인으로 사용하겠다는 선언
  • IN : 인터넷
  • SOA(Start of Authority) : 인증 시작
  • root : 관리자 메일 주소
  • serial : 데이터 버전 수정 횟수
  • refresh : 2차 nameserver가 1차 nameserver 재조회하는 시간(새로 고침)
  • retry : refresh가 안될 경우 다시 재조회하는 시간(재시도)
  • expire : retry나 1차 nameserver에 데이터가 수정 및 삭제 되었을 경우 해당 정보를 삭제하는 시간(만료시간)
  • minimum : 최소 유지 기간
  • NS : nameserver
  • A : 호스트 레코드 (도메인을 IP로 연결)
  • AAAA : IPv6
  • PTR : A의 역방향 레코드(A레코드 하나당 똑같이 하나씩 존재함)
  • 라운드 로빈(www 사용)
    [root@dns /var/named]# vim ryu.com.zone
    $TTL 1D
    @ SOA @ root. ( 0 1D 1H 1W 3H )
    IN NS @
    IN A 192.168.100.10

www IN A 192.168.100.101
IN A 192.168.100.102

  • 라운드 로빈(CNAME 사용) - 교재 P518
    [root@dns /var/named]# vim ryu.com.zone
    $TTL 1D
    @ SOA @ root. ( 0 1D 1H 1W 3H )
    IN NS @
    IN A 192.168.100.10

www IN CNAME webserver.ryu.com.
webserver 100 IN A 192.168.100.101
200 IN A 192.168.100.102

  • Nginx
    [root@nginx ~]# chmod u+w /etc/sudoers
    [root@nginx ~]# yum install -y vim
    [root@nginx ~]# vim /etc/sudoers
    ....
    100번째 줄쯤에
    root ALL=(ALL) ALL
    centos ALL=(ALL) ALL
    ...

:wq

[오류검출][root@dns ~]# named-checkzone ryu.com /var/named/ryu.com.zone

저장소 업데이트

[root@nginx ~]# yum install -y epel-release

nginx 저장소 생성

[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

:wq

nginx 설치

[root@localhost ~]# yum install -y nginx
....

방화벽 설정

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=http
[root@localhost ~]# firewall-cmd --reload
[root@nginx ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens32
sources:
services: dhcpv6-client http ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

[root@nginx ~]# systemctl restart nginx
[root@nginx ~]# systemctl status nginx

  • Client 에서 작업
    웹브라우저에서 192.168.100.11 로 접속
  • DNS 서버에서 작업
    [root@dns /var/named]# vim ryu.com.zone
    $TTL 1D
    @ SOA @ root. ( 0 1D 1H 1W 3H )
    IN NS @
    IN A 192.168.100.10

www IN A 192.168.100.11

:wq

[root@dns /var/named]# systemctl restart named

profile
클라우드 엔지니어가 되고싶은 클린이

0개의 댓글