웹사이트 검색

Debian 11에서 Nginx 및 SSL로 Etherpad를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 패키지 종속성 설치
  3. MariaDB 데이터베이스 설치 및 구성
  4. Etherpad 설치 및 구성
  5. Nginx 설치 및 구성
  6. Etherpad 설치 확인\n
  7. 결론

Etherpad는 Google Docs 및 Zoho Writer와 같은 서비스에 대한 무료 오픈 소스 대안입니다. Etherpad는 팀을 위한 공동 작업 및 실시간 텍스트 편집기이며 Etherpad는 웹 기반 텍스트 편집기이기 때문에 언제 어디서나 액세스할 수 있습니다.

Etherpad의 모든 변경 사항은 실시간으로 발생하며 etherpad는 팀을 위한 버전 관리 및 기본 제공 서식을 지원합니다. Etherpad는 다양한 플러그인을 지원하는 고도로 사용자 정의 가능한 편집기입니다. 또한 doc, pdf, odt, markdown 등과 같은 최신 문서 형식도 지원합니다.

이 튜토리얼에서는 Debian 11 Bullseye에 Etherpad Real-time Collaborative Editor를 설치하고 구성합니다. 이 튜토리얼은 MariaDB를 데이터베이스 백엔드로 사용하고 Nginx 웹 서버를 보안 HTTPS가 활성화된 리버스 프록시로 사용합니다. 결국 보안 HTTPS 암호화를 통해 Etherpad를 설치하고 보호하게 됩니다.

전제 조건

이 자습서를 완료하려면 먼저 다음 요구 사항이 필요합니다.

  • Debian 11 서버, 테스트용으로 1GB RAM을 사용할 수 있습니다. 프로덕션의 경우 환경 및 사용량에 따라 더 많은 리소스를 사용할 수 있습니다.\n
  • 루트 권한이 있는 루트가 아닌 사용자. 선택적으로 루트 사용자를 사용할 수 있습니다.\n
  • 설치를 위한 도메인 이름이며 서버 IP 주소를 가리키는지 확인하십시오. 이 예에서는 etherpad.example.io 도메인을 사용하는 것이 좋습니다.\n

이러한 전제 조건을 모두 갖추었다면 첫 번째 섹션으로 진행하여 설치를 시작하십시오.

패키지 종속성 설치

Etherpad는 Node.js 위에 구축된 웹 애플리케이션입니다. 이 글을 쓰는 시점에서 Etherpad 최신 버전은 xxx이며 Node.js 버전 14.x 이상이 필요합니다. 이 섹션에서는 Debian 11 서버에 대한 Node.js를 포함하여 일부 패키지 종속성을 설치합니다.

1. 먼저 패키지 인덱스 목록을 새로 고친 후 다음 명령을 실행하여 빌드 종속성을 설치합니다.

sudo apt update
sudo apt install gzip git curl python libssl-dev pkg-config gcc g++ make build-essential -y

2. 이 자습서에서는 여러 버전의 Node.js를 제공하는 Nodesource 리포지토리에서 Node.js를 설치합니다. 이 자습서에서는 Etherpad 설치에 Node.js 버전 16.x를 사용합니다.

이제 다음 명령을 실행하여 시스템에 Node.js 리포지토리를 추가합니다. 이 명령은 Nodesource 저장소를 자동으로 추가하여 패키지 색인을 새로 고칩니다.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

3. 다음으로 아래 명령을 실행하여 Nodesource 리포지토리에서 Node.js 16.x를 설치합니다.

sudo apt install nodejs -y

4. 설치가 완료되면 다음 명령을 사용하여 Node.js 버전을 확인합니다.

node --version

blah blah와 같은 출력을 받게 됩니다.

이 섹션에서는 Nodesource 리포지토리에서 Etherpad 및 Node.js 버전 16.x에 대한 패키지 종속성을 설치했습니다. 다음으로 MariaDB 데이터베이스를 설치하고 구성합니다.

MariaDB 데이터베이스 설치 및 구성

이 섹션에서는 Debian 11 서버에 MariaDB 데이터베이스를 설치합니다. 그런 다음 MariaDB의 루트 암호를 설정하고 마지막으로 Etherpad의 새 데이터베이스와 사용자를 생성합니다.

1. 기본적으로 MariaDB 패키지는 Debian 11 리포지토리에서 사용할 수 있습니다. 다음 명령을 실행하여 설치하십시오.

sudo apt install mariadb-server -y

2. MariaDB 설치가 완료되면 자동으로 실행되어 활성화됩니다.

MariaDB는 MariaDB의 루트 암호 설정을 포함하여 MariaDB를 안전하게 배포하는 데 도움이 되는 명령줄 도구를 제공합니다. 아래와 같이 mysql_secure_installation 명령을 실행합니다.

mysql_secure_installation

이제 MariaDB 배포와 관련된 몇 가지 질문을 받고 루트 암호를 설정하라는 메시지가 표시됩니다.

3. mariaDB의 기본 루트 사용자는 비밀번호가 없으므로 ENTER를 누릅니다.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

4. 이제 unix_socket을 사용하여 인증 방법을 전환하라는 메시지가 표시됩니다. Y를 입력하여 동의합니다.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!

5. Y를 입력하여 MariaDB의 새 루트 암호를 설정합니다. 그런 다음 강력한 비밀번호를 입력하고 반복하십시오.

Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

6. 기본 MariaDB 설치는 익명 사용자와 함께 제공됩니다. 제거하려면 Y를 입력합니다.

Remove anonymous users? [Y/n] Y
 ... Success!

7. 이제 MariaDB 루트 사용자에 대한 원격 로그인을 비활성화합니다. 동의하려면 Y를 입력합니다.

Disallow root login remotely? [Y/n] Y
 ... Success!

8. 다음으로 Y를 입력하여 동의하고 기본 데이터베이스 테스트와 그 위에 있는 모든 권한을 제거합니다.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

9. 마지막으로 테이블 권한을 다시 로드하여 새 구성을 적용합니다. Y를 입력하여 동의하고 Enter 키를 누릅니다.

Reload privilege tables now? [Y/n] Y
 ... Success!

모든 구성이 완료되면 All done!과 같은 출력 메시지를 받게 됩니다. 아래.

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

10. 그런 다음 다음 명령을 실행하여 MariaDB 셸에 로그인합니다. MariaDB 루트 암호를 입력하라는 메시지가 표시됩니다. 비밀번호를 입력하세요.

mysql -u root -p

11. 이제 다음 쿼리를 실행하여 Etherpad에 대한 새 데이터베이스와 사용자를 생성합니다. 이 예제는 사용자 etherpaduser와 비밀번호 StrongPasswordEtherpadDB로 새 데이터베이스 etherpad_lite_db를 생성합니다. 반드시 비밀번호를 변경하세요.

CREATE DATABASE etherpad_lite_db;
CREATE USER [email ;

12. 그런 다음 모든 테이블 권한을 다시 로드하여 새 구성을 적용한 다음 종료 쿼리를 실행하여 mariaDB 셸에서 로그아웃합니다.

FLUSH PRIVILEGES;
EXIT

이 섹션에서는 Debian 11에서 MariaDB 데이터베이스의 설치 및 구성을 완료했습니다. 또한 Etherpad용 데이터베이스 및 사용자를 생성했습니다. 다음으로 Etherpad 소스 코드를 다운로드하여 설치합니다.

Etherpad 설치 및 구성

이 섹션에서는 소스 코드에서 Etherpad를 설치한 다음 MariaDB를 데이터베이스로 구성하고 Etherpad용 새 시스템 파일을 만듭니다. 결국 Etherpad는 시스템 서비스로 실행될 것입니다.

1. Etherpad 소스 코드를 다운로드하기 전에 시스템에 새 사용자 etherpad를 생성할 것입니다. 이 사용자는 Etherpad 설치 프로그램 스크립트를 실행하고 Etherpad 서비스를 실행하는 데 사용됩니다.

아래의 adduser 명령을 실행하여 새 사용자 etherpad를 만듭니다. 또한 홈 디렉토리를 /opt/etherpad-lite로 정의하십시오. 이 디렉토리는 모든 Etherpad 소스를 저장하는 데 사용됩니다.

sudo adduser --system --no-create-home --home=/opt/etherpad-lite --group etherpad

2. 이제 /opt 디렉토리로 이동하고 git 명령을 사용하여 Etherpad 소스를 복제합니다.

cd /opt/
git clone --branch master https://github.com/ether/etherpad-lite.git

3. 그런 다음 etherpad-lite 디렉토리의 소유권을 사용자 etherpad 및 그룹 etherpad로 변경합니다.

sudo chown -R etherpad:etherpad etherpad-lite

4. 이제 etherpad-lite/ 디렉토리로 이동하고 아래와 같이 설치 프로그램 스크립트 installDeps.sh를 사용하여 모든 Node.js 종속성을 설치합니다. 설치 스크립트 installDeps.sh는 비루트 사용자 etherpad로 실행됩니다.

cd /opt/etherpad-lite
sudo su -s /bin/bash -c "./bin/installDeps.sh" etherpad

모든 패키지 종속성 설치가 완료될 때까지 기다리십시오.

다음으로 settings.json 파일을 수정하여 Etherpad 설치를 설정하십시오. 나노 편집기를 사용하여 해당 파일을 편집하거나 선호하는 편집기를 사용할 수 있습니다.

nano settings.json

줄 맨 위에서 자신의 제목으로 제목을 변경합니다. 이 예에서는 제목 Entherpad Johndoe를 사용합니다.

  "title": "Etherpad Johndoe",

이 튜토리얼에서 Etherpad는 Nginx 리버스 프록시에서 실행됩니다. 그리고 localhost에서 Etherpad를 실행하는 것이 보안상 좋습니다. 이제 ip: 구성을 127.0.0.1으로 변경합니다. 이 구성으로 Etherpad는 로컬 호스트에서만 실행됩니다.

  "ip": "127.0.0.1",
  "port": 9001,

기본적으로 Etherpad는 SQLite를 데이터베이스로 사용합니다. 비활성화하려면 이 줄을 모두 주석 처리하십시오.

  /*
  *"dbType": "dirty",
  *"dbSettings": {
  *  "filename": "var/dirty.db"
  *},
  */

이제 아래에 MariaDB 데이터베이스 구성을 입력하십시오. 그리고 데이터베이스 이름, 사용자 및 암호를 변경했는지 확인하십시오.

  "dbType" : "mysql",
  "dbSettings" : {
    "user":     "etherpaduser",
    "host":     "localhost",
    "port":     3306,
    "password": "StrongPasswordEtherpadDB",
    "database": "etherpad_lite_db",
    "charset":  "utf8mb4"
  },

파일을 저장하고 종료합니다.

다음으로 /etc/systemd/system 디렉토리에 새로운 systemd 서비스 파일 etherpad.service를 만듭니다. 이 파일에는 Etherpad가 서버에서 제대로 실행되는 데 필요한 모든 구성 세부 정보가 포함됩니다. nano 편집기를 사용하여 만듭니다.

sudo nano /etc/systemd/system/etherpad.service

파일에 다음 구성을 추가합니다.

[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target

[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/opt/etherpad-lite
Environment=NODE_ENV=production
ExecStart=/usr/bin/node --experimental-worker /opt/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js
# use mysql plus a complete settings.json to avoid Service hold-off time over, scheduling restart.
Restart=always

[Install]
WantedBy=multi-user.target

이 서비스 파일은 사용자 및 그룹 etherpad로 실행됩니다. 그리고 Environment=NODE_ENV=production 옵션이 있음을 알게 될 것입니다. 이는 Etherpad 응용 프로그램이 프로덕션 환경에서 실행될 것임을 의미합니다. ExecStart=.. 옵션은 Etherpad 응용 프로그램을 실행하기 위한 기본 명령입니다.

파일을 저장하고 닫습니다.

이제 시스템 관리자를 다시 로드하여 새 서비스 파일을 적용합니다.

sudo systemctl daemon-reload

그런 다음 etherpad 서비스를 시작하고 활성화한 후 다음 명령을 실행하여 상태를 확인합니다.

sudo systemctl enable --now etherpad
sudo systemctl status etherpad

아래 스크린샷과 유사한 출력이 표시됩니다. 이제 etherpad 서비스가 활성화(실행 중)되고 시스템 시작 시 자동으로 시작되며 기본 포트 9001로 localhost에서 실행됩니다.

이제 Etherpad 설치가 완료되었습니다. 다음으로 Nginx를 설치하여 Etherpad 애플리케이션의 리버스 프록시로 설정합니다.

Nginx 설치 및 구성

프로덕션 환경의 경우 항상 애플리케이션 앞에 리버스 프록시를 배치하는 것이 좋습니다. 애플리케이션 성능과 보안이 향상됩니다. 이 섹션에서는 Nginx 웹 서버를 리버스 프록시로 설치 및 구성합니다. 결국 Etherpad는 도메인 이름으로 실행되고 HTTPS 프로토콜로 보호됩니다.

1. 먼저 아래 명령을 실행하여 Nginx 패키지를 설치합니다.

sudo apt install nginx -y

2. 이제 데비안 시스템에 UFW 방화벽이 있는 경우. 아래의 ufw 명령을 실행하여 HTTP 및 HTTPS 포트(80 및 443)에 대한 공개 액세스를 허용합니다.

sudo ufw allow "Nginx Full"

다음 출력을 받게 됩니다.

Rule added
Rule added (v6)

3. 다음으로 /etc/nginx/sites-available/ 디렉토리에 새로운 Nginx 가상 호스트 파일 etherpad를 만듭니다. 나노 편집기 또는 선호하는 편집기를 사용하여 생성합니다.

sudo nano /etc/nginx/sites-available/etherpad

다음 구성을 복사하여 파일에 붙여넣습니다. 또한 도메인 이름과 SSL 인증서 경로를 자신의 정보로 바꾸십시오. SSL 인증서의 경우 Letsencrypt를 사용하여 자유롭게 SSL 인증서를 생성할 수 있습니다.

# enforce HTTPS
server {
    listen       80;
    listen       [::]:80;
    server_name  etherpad.example.io;
    return 301   https://$host$request_uri;
}

# we're in the http context here
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  etherpad.example.io;

    access_log  /var/log/nginx/eplite.access.log;
    error_log   /var/log/nginx/eplite.error.log;

    ssl_certificate      /etc/letsencrypt/live/etherpad.example.io/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/etherpad.example.io/privkey.pem;

    ssl_session_timeout  5m;

    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 \
    EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 \
    EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";

    location / {
        proxy_pass         http://127.0.0.1:9001;
        proxy_buffering    off; # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
        proxy_set_header   Host $host;
        proxy_pass_header  Server;

        # Note you might want to pass these headers etc too.
        proxy_set_header    X-Real-IP $remote_addr; # https://nginx.org/en/docs/http/ngx_http_proxy_module.html
        proxy_set_header    X-Forwarded-For $remote_addr; # EP logs to show the actual remote IP
        proxy_set_header    X-Forwarded-Proto $scheme; # for EP to set secure cookie flag when https is used
        proxy_http_version  1.1; # recommended with keepalive connections

        # WebSocket proxying - from https://nginx.org/en/docs/http/websocket.html
        proxy_set_header  Upgrade $http_upgrade;
        proxy_set_header  Connection $connection_upgrade;
    }
}

이 Nginx 가상 호스트 파일은 HTTP에서 보안 HTTPS 프로토콜로 모든 트래픽을 자동으로 리디렉션합니다. 오류가 있는 경우 디버깅을 위해 로그 파일 /var/log/nginx/eplite.error.log를 확인하십시오. 모든 클라이언트 요청은 localhost 포트 9001에서 실행되는 Etherpad 애플리케이션의 백엔드 proxy_pass로 전송됩니다.

4. 파일을 저장하고 닫은 다음 /etc/nginx/sites-enabled 디렉토리에 etherpad 파일의 심볼릭 링크를 만들어 가상 호스트 구성을 활성화합니다.

sudo ln -s /etc/nginx/sites-available/etherpad /etc/nginx/sites-enabled/

5. 다음으로 nginx -t 명령을 실행하여 nginx 구성을 확인합니다. 이 명령은 구성의 구문 오류를 확인합니다.

sudo nginx -t

아래와 같이 출력을 받게 됩니다. 출력 메시지 구문이 괜찮다는 것은 오류가 없음을 의미합니다.

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

6. 마지막으로 Nginx 서비스를 다시 시작하여 새 Nginx 가상 호스트 파일을 적용합니다.

sudo systemctl restart nginx

이 섹션에서는 Nginx 설치 및 Etherpad 애플리케이션용 리버스 프록시 구성을 완료했습니다. 이제 Etherpad를 http://etherpad.example.io에서 사용할 수 있습니다.

Etherpad 설치 확인

1. 웹 브라우저를 열고 주소에 도메인 이름 http://etherpad.example.io/를 입력합니다. 그러면 아래와 같이 보안 HTTPS 연결로 자동 리디렉션됩니다.

2. 새 패드를 생성하려면 열에 패드 이름을 입력하고 확인 버튼을 클릭합니다.

이제 아래와 같이 Etherpad 실시간 협업 편집기가 표시됩니다.

결론

이 튜토리얼에서는 Debian 11 서버에 Etherpad Real-time Collaborative Editor를 설치하고 구성했습니다. 또한 Nginx를 Etherpad 응용 프로그램의 리버스 프록시로 설치 및 구성했습니다.

이제 팀에서 협업 편집기로 etherpad를 사용할 준비가 되었습니다. Etherpad에 대한 자세한 내용은 공식 Etherpad 설명서를 확인하십시오.