Ubuntu Linux에서 Zabbix HTTPS 설치

이 튜토리얼은 Ubuntu Linux에서 HTTPS를 사용하여 Zabbix 4를 설치하는 데 필요한 모든 단계를 보여줍니다.

이 자습서에서는 Let 's Encrypt - Free SSL / TLS 인증서를 사용합니다.

이 튜토리얼은 Ubuntu 18.04에서 테스트되었습니다.

1. NTP를 사용하여 날짜 및 시간 구성

시스템을 올바른 날짜와 시간으로 유지하는 것은 매우 중요합니다.

올바른 시간대를 설정하십시오.

# dpkg-reconfigure tzdata

Ntpdate 패키지를 설치하고 올바른 날짜와 시간을 설정하십시오.

# apt-get update
# apt-get install ntpdate
# ntpdate pool.ntp.br

우분투 기본 NTP 클라이언트를 비활성화하십시오.

NTP 서비스를 설치하여 재부팅 후 컴퓨터의 날짜와 시간을 업데이트하십시오.

# timedatectl set-ntp 0
# apt-get install ntp

컴퓨터에 올바른 날짜와 시간이 설정되어 있는지 확인하십시오.

# date

2. 우분투 리눅스에 MySQL 설치하기

Zabbix는 모든 구성을 저장하기 위해 데이터베이스 시스템이 필요합니다.

Ubuntu APT 명령을 사용하여 MySQL 서버를 설치하십시오.

# apt-get update
# apt-get install mysql-server mysql-client

다음 명령을 사용하여 MySQL 서비스 콘솔에 액세스하십시오.

# mysql -u root -p

MySQL 콘솔에서 다음 작업을 수행해야합니다.

• zabbix라는 데이터베이스를 만듭니다.
• zabbix라는 MySQL 사용자 계정을 만듭니다.
• zabbix 사용자에게 zabbix 데이터베이스에 대한 모든 권한을 부여하십시오.

CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;
CREATE USER 'zabbix'@'%' IDENTIFIED BY 'kamisama123';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%';
quit;

데이터베이스 템플릿을 얻으려면 Zabbix 설치 패키지를 다운로드하십시오.

# mkdir /downloads
# cd /downloads
# wget https://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz

Zabbix 설치 패키지의 압축을 풉니 다.

Zabbix 데이터베이스 템플릿을 MySQL 데이터베이스로 가져옵니다.

질문을 받으면 Zabbix 사용자의 MySQL 암호를 입력해야합니다.

# tar -zxvf zabbix-4.0.3.tar.gz
# cd zabbix-4.0.3/database/mysql/
# mysql -u zabbix -p zabbix < schema.sql
# mysql -u zabbix -p zabbix < images.sql
# mysql -u zabbix -p zabbix < data.sql

Zabbix 데이터베이스 설치가 완료되었습니다.

3. 우분투 리눅스에 아파치 설치하기

Apache 서버와 필수 PHP 모듈을 설치하려면 Ubuntu APT 명령을 사용하십시오.

# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# apt-get install php7.2-mbstring php7.2-xml php7.2-gd
# apt-get install php7.2-curl php7.2-bcmath php7.2-ldap

Apache mod_ssl을 활성화하십시오.

Apache mod_rewrite를 활성화하십시오.

apache2.conf 파일을 편집하십시오.

# a2enmod ssl
# a2enmod rewrite
# vi /etc/apache2/apache2.conf

apache2.conf 끝에 다음 행을 추가하십시오.

<Directory /var/www/html>
AllowOverride All
</Directory>

시스템에서 PHP 구성 파일의 위치를 찾으십시오.

php.ini 구성 파일을 편집하십시오.

# updatedb
# locate php.ini
# vi /etc/php/7.2/apache2/php.ini

귀하의 PHP 버전이 우리와 다를 수 있습니다.

귀하의 PHP 구성 파일 위치가 우리와 다를 수 있습니다.

php.ini 구성 파일에서 다음 항목을 수정하십시오.

max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
max_input_time = 300
date.timezone = America/Sao_Paulo

시간대가 우리와 다를 수 있습니다.

Apache 웹 서버를 수동으로 다시 시작하십시오.

# service apache2 restart
# service apache2 status

Apache 서비스 상태를 확인하십시오.

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Mon 2018-12-03 03:41:12 -02; 2 days ago

Apache 서버 설치가 완료되었습니다.

4. 아파치 가상 호스트 설정하기

하나의 Apache 서버가 동일한 IP 주소를 사용하는 여러 웹 사이트를 제공 할 수있는 기능인 경우 가상 호스트.

Apache VirtualHosts 기능을 사용하기 위해 필요한 인프라를 생성 할 수 있습니다.

# mkdir /websites/zabbix -p
# cd /websites/zabbix
# mkdir www logs
# chown www-data.www-data /websites -R

우리 웹 사이트의 이름은 zabbix.mining-pool.ninja입니다.

zabbix.mining-pool.ninja 웹 사이트 파일은 / websites / zabbix / www 디렉토리에 있어야합니다.

zabbix.mining-pool.ninja 로그는 / websites / zabbix / logs 디렉토리에 저장됩니다.

Alert!

Zabbix.mining-pool.ninja was used as an example!

You need to change the configuration files to reflect your Zabbix website name.

Zabbix 웹 사이트에 대한 Apache Virtualhost 구성 파일을 만듭니다.

# vi /etc/apache2/sites-available/zabbix.conf

여기에 우리의 구성 파일이 있습니다.

<VirtualHost *:80>
ServerAdmin nobody@care.com
DocumentRoot /websites/zabbix/www
ServerName zabbix.mining-pool.ninja

<Directory /websites/zabbix/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/zabbix/logs/error.log
CustomLog /websites/zabbix/logs/access.log combined
LogLevel error
</VirtualHost>

Zabbix Virtualhost 웹 사이트 설정 파일을 활성화하십시오.

Apache 서비스를 다시 시작하십시오.

# a2ensite zabbix.conf
# service apache2 restart

Apache VirtualHosts 설정을 마쳤습니다.

5. DNS 도메인 레지스트리 구성

액세스 GODADDY DNS 도메인을 구입할 수 있습니다.

이 예에서는 MINING-POOL.NINJA라는 도메인을 구입합니다.

어떤 웹 사이트라도 DNS 도메인을 구입할 수 있습니다. GoDaddy는 제 개인적인 선택입니다.

Zabbix 웹 사이트가 Apache를 실행하는 컴퓨터를 가리키는 DNS 항목을 만듭니다.

이 예에서는 IP 주소 34.217.177.160에 ZABBIX.MINING-POOL.NINJA를 가리키는 DNS 항목을 만들었습니다.

Zabbix virtual host dns

NSLOOKUP 명령을 사용하여 DNS 구성을 테스트하십시오.

# apt-get update
# apt-get install dnsutils
# nslookup zabbix.mining-pool.ninja

Non-authoritative answer:
Name: zabbix.mining-pool.ninja
Address: 34.217.177.160

DNS 도메인 구성을 마쳤습니다.

브라우저를 열고 웹 사이트의 HTTP 버전에 액세스하십시오.

이 예에서는 브라우저에 다음 URL이 입력되었습니다.

• http://zabbix.mining-pool.ninja

Zabbix HTTP Virtual Host

이제 무료 HTTPS 인증서를 설치해야합니다.

또한 모든 HTTP 트래픽을 자동으로 Zabbix 웹 사이트의 HTTPS 버전으로 리디렉션해야합니다.

6. Apache에서 Free HTTPS 인증서 구성

Ubuntu Linux에서 LET 'S ENCRYPT Free SSL / TLS 인증서를 사용하려면 필요한 패키지를 설치하십시오.

# apt-get install software-properties-common
# add-apt-repository universe
# add-apt-repository ppa:certbot/certbot
# apt-get update
# apt-get install python-certbot-apache

Apache 무료 HTTPS 인증서를 요청하고 설치하십시오.

# certbot --apache -d mining-pool.ninja

• (A)를 눌러 서비스 약관에 동의하십시오.
• (Y)를 눌러 전자 메일을 공유하고 뉴스 레터를 수신하십시오.
• (2)를 눌러 HTTP 웹 사이트를 HTTPS 버전으로 자동 리디렉션합니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): techexpert.tips@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for zabbix.mining-pool.ninja
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/zabbix-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/zabbix-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/zabbix-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/zabbix.conf to ssl vhost in /etc/apache2/sites-available/zabbix-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://zabbix.mining-pool.ninja

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=zabbix.mining-pool.ninja
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/zabbix.mining-pool.ninja/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/zabbix.mining-pool.ninja/privkey.pem
Your cert will expire on 2019-04-09. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

시스템에서 자동으로 무료 인증서를 요청합니다.

또한 모든 HTTP 액세스를 웹 사이트의 HTTPS 버전으로 리디렉션하도록 Apache 웹 서버를 구성합니다.

이 예에서 시스템은 zabbix-le-ssl.conf라는 HTTPS Virtualhost 구성 파일을 만들었습니다.

다음은 HTTPS Virtualhost 구성 파일 zabbix-le-ssl.conf의 내용입니다.

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin nobody@care.com
DocumentRoot /websites/zabbix/www
ServerName zabbix.mining-pool.ninja

<Directory /websites/zabbix/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/zabbix/logs/error.log
CustomLog /websites/zabbix/logs/access.log combined
LogLevel error

SSLCertificateFile /etc/letsencrypt/live/zabbix.mining-pool.ninja/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/zabbix.mining-pool.ninja/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

KEY 파일에는 인증서 개인 키가 포함되어 있으며 항상 안전한 장소에 보관해야합니다.

mining-pool.ninja의 핵심 파일은 /etc/letsencrypt/live/zabbix.mining-pool.ninja/privkey.pem에 저장되었습니다.

시스템은 원래 Apache Virtualhost 구성 파일을 자동으로 수정합니다.

모든 HTTP 요청을 자동으로 웹 사이트의 HTTPS 버전으로 리디렉션합니다.

업데이트 된 원본 HTTP 가상 호스트 구성 파일 인 zabbix.conf의 내용은 다음과 같습니다.

<VirtualHost *:80>
ServerAdmin nobody@care.com
DocumentRoot /websites/zabbix/www
ServerName zabbix.mining-pool.ninja

<Directory /websites/zabbix/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/zabbix/logs/error.log
CustomLog /websites/zabbix/logs/access.log combined
LogLevel error
RewriteEngine on
RewriteCond %{SERVER_NAME} =zabbix.mining-pool.ninja
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

7. Apache에서 무료 HTTPS 인증서 테스트

필요한 모든 구성이 완료되었습니다.

이제 구성을 테스트 할 차례입니다.

브라우저를 열고 웹 사이트의 HTTP 버전에 액세스하십시오.

이 예에서는 브라우저에 다음 URL이 입력되었습니다.

• http://zabbix.mining-pool.ninja

Apache는 자동으로 HTTP 요청을 웹 사이트의 HTTPS 버전으로 리디렉션합니다.

Zabbix HTTPS Virtual Host

Apache HTTPS 무료 인증서 구성을 마쳤습니다.

8. Ubuntu Linux에 Zabbix 4를 설치하십시오.

MySQL과 아파치 설정을 마치면 Zabbix 설치를 시작할 수있다.

Zabbix 서비스에 필요한 사용자 계정을 만듭니다.

# groupadd zabbix
# useradd -g zabbix -s /bin/bash zabbix

Ubuntu APT 명령을 사용하여 필요한 패키지를 설치하십시오.

# apt-get install build-essential libmysqlclient-dev libssl-dev libsnmp-dev libevent-dev
# apt-get install libopenipmi-dev libcurl4-openssl-dev libxml2-dev libssh2-1-dev libpcre3-dev
# apt-get install libldap2-dev libiksemel-dev libcurl4-openssl-dev libgnutls28-dev

Zabbix 설치 패키지가 다운로드 된 디렉토리에 액세스하십시오.

Zabbix 서버 응용 프로그램을 컴파일하고 설치하십시오.

# cd /downloads/zabbix-4.0.3/
# ./configure --enable-server --enable-agent --with-mysql --with-openssl --with-net-snmp --with-openipmi --with-libcurl --with-libxml2 --with-ssh2 --with-ldap
# make
# make install

시스템에서 Zabbix 서버 구성 파일의 위치를 찾으십시오.

zabbix_server.conf 구성 파일을 편집하십시오.

# updatedb
# locate zabbix_server.conf
# vi /usr/local/etc/zabbix_server.conf

여기에 우리의 구성 이전의 원본 파일이 있습니다.

LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
Timeout=4
LogSlowQueries=3000

우리의 구성을 가진 새로운 파일이 있습니다.

LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=kamisama123
Timeout=4
LogSlowQueries=3000

다음 명령을 사용하여 Zabbix 서버를 시작하십시오.

# /usr/local/sbin/zabbix_server

다음 명령을 사용하여 Zabbix 에이전트 응용 프로그램을 시작하십시오.

# /usr/local/sbin/zabbix_agentd

선택 과목! Zabbix 설치 패키지는 서비스 시작 스크립트를 제공합니다.

Zabbix 시작 스크립트를 복사하십시오.

# cd /downloads/zabbix-4.0.3/
# cp misc/init.d/debian/* /etc/init.d/

이제 다음 명령을 사용하여 Zabbix 서버 서비스를 시작할 수 있습니다.

# /etc/init.d/zabbix-server start

이제 다음 명령을 사용하여 Zabbix 서버 서비스를 중지 할 수 있습니다.

# /etc/init.d/zabbix-server stop

Zabbix 프론트 엔드 파일을 Apache 루트 드라이브 디렉토리로 이동하십시오.

www 데이터 사용자에게 Zabbix 디렉토리 및 파일에 대한 모든 권한을 부여하십시오.

# cd /downloads/zabbix-4.0.3/frontends
# cp php/* /websites/zabbix/www/ -R
# chown www-data.www-data /websites/zabbix/www -R

Apache 서비스를 다시 시작하십시오.

# service apache2 stop
# service apache2 start

9. Ubuntu Linux에서 Zabbix 구성

브라우저를 열고 Zabbix 웹 사이트의 HTTPS 버전에 액세스하십시오.

이 예에서는 브라우저에 다음 URL이 입력되었습니다.

• https://zabbix.mining-pool.ninja

Zabbix 설치 마법사가 나타납니다.

Zabbix Installation

모든 Zabbix 요구 사항이 성공적으로 충족되었는지 확인하십시오.

Zabbix Requirements

Zabbix 데이터베이스에 연결하는 데 필요한 MySQL 로그인 정보를 입력하십시오.

Zabbix database connetion

다음 버튼을 클릭하십시오.

Zabbix Agent Connection

Zabbix 설치 요약을 확인하십시오.

Zabbis Installation Summary

마침 버튼을 클릭하여 Zabbix 로그인 화면에 액세스하십시오.

Zabbix installation finished

Zabbix 로그인 화면에서 다음 정보를 입력하십시오.

• Zabbix 기본 사용자 이름 : Admin
• Zabbix 기본 암호 : zabbix

Zabbix Login

로그인이 성공하면 Zabbix 대시 보드가 표시됩니다.

Zabbix Dashboard

축하합니다. Zabbix가 시스템에 설치되었습니다.

10. Zabbix 서버 모니터링

Zabbix 서버는 자신을 모니터 할 수 있어야합니다.

Zabbix 대시 보드에서 Configuration 메뉴에 액세스하고 Host 옵션을 선택합니다.

Zabbix menu

화면 오른쪽 상단에서 Zabbix 서버라는 옵션을 선택하십시오.

Zabbix Server Group

Zabbix 서버라는 호스트를 찾고 DISABLED라는 단어를 클릭하십시오.

그러면 Zabbix 서버가 자체 모니터 할 수 있습니다.

Zabbix server agent disabled

Zabbix 서버 상태가 DISABLED에서 ENABLED로 바뀝니다.

Zabbix server agent enabled

Zabbix 서버가 현재 자체 모니터링 중입니다.

11. 무료 HTTPS 인증서를 갱신하는 방법

LET 'S ENCRYPT 무료 SSL / TLS 인증서는 90 일 동안 만 유효합니다.

시스템은 만료 된 후 30 일 이내에 모든 인증서를 자동으로 갱신하는 스케줄 된 태스크를 작성합니다.

예약 된 작업 이름은 certbot이며 /etc/cron.d 디렉토리에 있습니다.

다음은 /etc/cron.d/certbot 파일의 내용입니다.

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
#
# Important Note! This cronjob will NOT be executed if you are
# running systemd as your init system. If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob. For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

인증서 갱신 프로세스를 시뮬레이트하려면 다음 명령을 사용하십시오.

# certbot renew --dry-run

다음 메시지가 표시됩니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/zabbix.mining-pool.ninja.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for zabbix.mining-pool.ninja
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/zabbix.mining-pool.ninja/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)

Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/zabbix.mining-pool.ninja/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.