웹사이트 검색

Ubuntu 18.04에 Mailtrain 뉴스레터 소프트웨어를 설치하는 방법


이 페이지에서

  1. 요구 사항\n
  2. 시작하기\n
  3. Docker 및 Docker Compose 설치
  4. Docker로 Mailtrain 설치
  5. Mailtrain 웹 인터페이스 액세스
  6. Nginx를 Mailtrain용 리버스 프록시로 구성\n
  7. Lets Encrypt로 안전한 Mailtrain\n
  8. 결론

Mailtrain은 MySQL/MariaDB 데이터베이스 백엔드를 지원하는 Node.js로 구축된 무료 오픈 소스 자체 호스팅 뉴스레터 애플리케이션입니다. Mailtrain을 사용하면 API를 통해 구독자를 수동으로 추가하거나 CSV 파일에서 가져올 수 있습니다. Mailtrain은 템플릿 편집기, 자동화, 사용자 정의 필드, RSS 캠페인, HTML 코드 편집기 등을 포함한 다양한 기능 세트와 함께 제공됩니다. 구독자 목록이 많고 쉽게 관리하고 싶다면 Mailtrain이 최선의 선택입니다.

이 튜토리얼에서는 Ubuntu 18.04 서버에 Docker를 사용하여 Mailtrain 뉴스레터 애플리케이션을 설치하는 방법을 보여줍니다.

요구 사항

  • Ubuntu 18.04를 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 서버에 루트 암호가 구성되어 있습니다.\n

시작하기

시작하기 전에 시스템을 최신 버전으로 업데이트해야 합니다. 다음 명령을 실행하여 이를 수행할 수 있습니다.

apt-get update -y
apt-get upgrade -y

그런 다음 시스템을 다시 시작하여 변경 사항을 적용하십시오.

Docker 및 Docker Compose 설치

기본적으로 Docker의 최신 버전은 Ubuntu 18.04 기본 리포지토리에서 사용할 수 없습니다. 따라서 시스템에 Docker 리포지토리를 추가해야 합니다.

먼저 다음 명령을 사용하여 필요한 패키지를 설치합니다.

apt-get install curl git apt-transport-https ca-certificates -y

다음으로 다음 명령을 사용하여 Docker의 PGP 키를 다운로드하고 추가합니다.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

다음으로 /etc/apt/sources.list 파일을 편집하여 Docker CE 리포지토리를 추가합니다.

nano /etc/apt/sources.list

파일 끝에 다음 줄을 추가합니다.

deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

완료되면 파일을 저장하고 닫습니다. 그런 다음 리포지토리를 업데이트하고 다음 명령을 사용하여 Docker CE를 설치합니다.

apt-get update -y
apt-get install docker-ce -y

설치가 성공적으로 완료되면 다음 명령을 사용하여 Docker 서비스의 상태를 확인할 수 있습니다.

systemctl status docker

다음 출력이 표시되어야 합니다.

Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-10-24 16:15:25 UTC; 21min ago
     Docs: https://docs.docker.com
 Main PID: 1402 (dockerd)
    Tasks: 45
   CGroup: /system.slice/docker.service
           ?? 1402 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ??10312 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3000 -container-ip 172.18.0.4 -container-port 3000

Oct 24 16:23:04 ubuntu1804 dockerd[1402]: time="2019-10-24T16:23:04.817021656Z" level=info msg="Layer sha256:b875b006eb8ffb0434ce3a26cb04c9017c
Oct 24 16:24:09 ubuntu1804 dockerd[1402]: time="2019-10-24T16:24:09.879265134Z" level=info msg="ignoring event" module=libcontainerd namespace=
Oct 24 16:24:10 ubuntu1804 dockerd[1402]: time="2019-10-24T16:24:10.065610315Z" level=warning msg="20676b10252b4a484e32a7d7534b3b386cc2a1e5efd1
Oct 24 16:25:52 ubuntu1804 dockerd[1402]: time="2019-10-24T16:25:52.649551513Z" level=info msg="Layer sha256:903ab9000f0a93e49537d5d00c5c8a8cab
Oct 24 16:26:47 ubuntu1804 dockerd[1402]: time="2019-10-24T16:26:47.428865652Z" level=info msg="Layer sha256:903ab9000f0a93e49537d5d00c5c8a8cab
Oct 24 16:27:41 ubuntu1804 dockerd[1402]: time="2019-10-24T16:27:41.603287585Z" level=info msg="Layer sha256:903ab9000f0a93e49537d5d00c5c8a8cab

다음으로 아래와 같이 pip 명령을 사용하여 최신 버전의 docker compose를 설치합니다.

apt-get install python-pip
apt-get install docker-compose

설치가 완료되면 다음 단계로 진행할 수 있습니다.

Docker로 Mailtrain 설치

먼저 다음 명령을 사용하여 Git 리포지토리에서 최신 버전의 Mailtrain을 다운로드합니다.

git clone git://github.com/Mailtrain-org/mailtrain.git

다음으로 디렉터리를 mailtrain으로 변경하고 기본 docker-compose 파일의 이름을 바꿉니다.

cd mailtrain
mv docker-compose.override.yml.tmpl docker-compose.override.yml

그런 다음 다음 명령을 사용하여 Mailtrain 도커 컨테이너를 시작합니다.

docker-compose up -d

이 명령은 아래와 같이 mailtrain, mysql 및 redis 컨테이너를 다운로드하고 시작합니다.

Creating network "mailtrain_default" with the default driver
Creating volume "mailtrain_mailtrain-node-config" with default driver
Creating volume "mailtrain_mailtrain-node-data" with default driver
Creating volume "mailtrain_mailtrain-redis-data" with default driver
Creating volume "mailtrain_mailtrain-node-reports" with default driver
Creating volume "mailtrain_mailtrain-mysq-data" with default driver
Pulling redis (redis:3.0)...
3.0: Pulling from library/redis
f5cc0ee7a6f6: Pull complete
5fc25ed18e87: Pull complete
e025bc8872f6: Pull complete
77c68b51b836: Pull complete
7c403ece3755: Pull complete
0a653bd338f4: Pull complete
31531fd948c6: Pull complete
Digest: sha256:730b765df9fe96af414da64a2b67f3a5f70b8fd13a31e5096fee4807ed802e20
Status: Downloaded newer image for redis:3.0
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
80369df48736: Pull complete
e8f52315cb10: Pull complete
cf2189b391fc: Pull complete
cc98f645c682: Pull complete
27a27ac83f74: Pull complete
fa1f04453414: Pull complete
d45bf7d22d33: Pull complete
c7d49ffebc56: Pull complete
511a8052b204: Pull complete
5d5df4c12444: Pull complete
d482603a2922: Pull complete
Digest: sha256:44b33224e3c406bf50b5a2ee4286ed0d7f2c5aec1f7fdb70291f7f7c570284dd
Status: Downloaded newer image for mysql:5.7
Building mailtrain
:
:
Removing intermediate container 20676b10252b
 ---> 0abdb4121f54
Step 6/9 : COPY . /app
 ---> c8af7560e844
Step 7/9 : EXPOSE 3000
 ---> Running in 3ff55179a229
Removing intermediate container 3ff55179a229
 ---> d83b49d4b24b
Step 8/9 : ENTRYPOINT ["bash", "/app/docker-entrypoint.sh"]
 ---> Running in e5baf6a1ea2e
Removing intermediate container e5baf6a1ea2e
 ---> c4f899a0f8f9
Step 9/9 : CMD ["node", "index.js"]
 ---> Running in fe94519d2bd3
Removing intermediate container fe94519d2bd3
 ---> 2808c2972f20
Successfully built 2808c2972f20
Successfully tagged mailtrain:latest
WARNING: Image for service mailtrain was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating mailtrain_redis_1 ... done
Creating mailtrain_mysql_1 ... done
Creating mailtrain_mailtrain_1 ... done

이제 다음 명령을 사용하여 실행 중인 모든 컨테이너를 확인할 수 있습니다.

docker ps

다음 출력이 표시되어야 합니다.

CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                    NAMES
0e837c586c39        mailtrain:latest    "bash /app/docker-en…"   About a minute ago   Up 55 seconds       0.0.0.0:3000->3000/tcp   mailtrain_mailtrain_1
49a4e69a09c6        mysql:5.7           "docker-entrypoint.s…"   About a minute ago   Up About a minute   3306/tcp, 33060/tcp      mailtrain_mysql_1
a1449b64a196        redis:3.0           "docker-entrypoint.s…"   About a minute ago   Up About a minute   6379/tcp                 mailtrain_redis_1

Mailtrain 웹 인터페이스에 액세스

이제 Mailtrain 컨테이너가 시작되고 포트 3000에서 수신 대기합니다. 다음으로 웹 브라우저를 열고 URL http://your-server-ip:3000을 입력합니다. 다음 페이지에 Mailtrain 기본 대시보드가 표시되어야 합니다.

이제 로그인 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

기본 사용자 이름과 비밀번호를 admin/admin으로 입력하고 로그인 버튼을 클릭합니다. 다음 페이지에 Mailtrain 기본 대시보드가 표시되어야 합니다.

Nginx를 Mailtrain의 역방향 프록시로 구성

다음으로 포트 3000에서 Mailtrain의 리버스 프록시로 Nginx를 생성해야 합니다. 이렇게 하려면 먼저 다음 명령을 실행하여 Nginx 웹 서버를 설치합니다.

apt-get install nginx -y

다음으로 다음 명령을 사용하여 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/sites-available/mailtrain.conf

다음 줄을 추가합니다.

upstream mailtrain {
  server 127.0.0.1:3000 weight=100 max_fails=5 fail_timeout=5;
}

server {
  listen          80;
  server_name     example.com;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://mailtrain/;
  }
}

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 Nginx에서 구문 오류가 있는지 확인합니다.

nginx -t

다음 출력이 표시되어야 합니다.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

다음으로 다음 명령을 사용하여 Nginx 가상 호스트 파일을 활성화합니다.

ln -s /etc/nginx/sites-available/mailtrain.conf /etc/nginx/sites-enabled/

마지막으로 Nginx 웹 서버를 다시 시작하여 구성을 적용합니다.

systemctl restart nginx

Lets Encrypt로 안전한 Mailtrain

다음으로 Lets Encrypt 무료 SSL로 Mailtrain을 보호하려면 Certbot 클라이언트를 설치해야 합니다. 기본적으로 최신 버전의 Certbot은 Ubuntu 18.04 기본 리포지토리에서 사용할 수 없습니다. 따라서 다음 명령을 실행하여 Certbot 리포지토리를 추가합니다.

add-apt-repository ppa:certbot/certbot

다음으로 다음 명령을 사용하여 리포지토리를 업데이트하고 Certbot을 설치합니다.

apt-get update -y
apt-get install certbot python-certbot-nginx -y

설치가 완료되면 다음 명령을 실행하여 도메인 example.com에 대한 Lets Encrypt 무료 SSL을 다운로드하고 이 인증서를 사용하도록 Nginx를 구성합니다.

certbot --nginx -d example.com

이메일 주소를 제공하고 서비스 약관에 동의합니다. 인증서가 성공적으로 설치되면 다음 출력이 표시됩니다.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2020-01-22. 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"
 - 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.
 - 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

이제 URL https://example.com을 사용하여 Mailtrain 애플리케이션에 안전하게 액세스할 수 있습니다.

결론

위의 튜토리얼에서는 Ubuntu 18.04 서버에 Docker를 사용하여 Mailtrain을 설치하는 방법을 배웠습니다. 또한 Nginx를 Mailtrain용 리버스 프록시로 구성하고 Lets Encrypt 무료 SSL을 사용하여 Mailtrain을 보호하는 방법도 배웠습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.