서버 설치 · 12 min read · Nov 01, 2025
Ubuntu 22.04에서 Matrix Synapse와 Element를 사용하여 채팅 서버 설치 및 생성하는 방법

Matrix는 분산형 및 종단 간 암호화 통신을 위한 개방형 표준입니다. 이는 서로 통신하는 서버 및 서비스의 모음으로, 표준화된 API를 사용하여 실시간으로 동기화됩니다. 홈 서버를 사용하여 계정 정보와 채팅 기록을 저장합니다. 하나의 홈 서버가 다운되더라도 분산화의 특성 덕분에 다른 서버는 문제 없이 통신을 계속할 수 있습니다. 다른 사람이 호스팅하는 Matrix 홈 서버를 사용할 수도 있고, 데이터를 제어하기 위해 직접 호스팅할 수도 있습니다.
이 튜토리얼에서는 Matrix의 홈 서버 구현인 Synapse를 사용하여 채팅 서버를 설치하고 생성하는 방법을 배웁니다. Element는 Matrix React SDK를 사용하여 구축된 Matrix 웹 클라이언트입니다. 이를 통해 웹에서 Matrix 채팅을 제공할 수 있습니다. 또한 원하는 다른 Matrix 클라이언트와 함께 서버를 사용할 수 있습니다. 음성 및 비디오 통화를 활성화하기 위해 Coturn 서버도 설치할 것입니다. Coturn 서비스는 사용하지 않으려면 선택 사항입니다.
필수 조건
- Ubuntu 22.04에서 실행되는 서버.
- 루트 권한이 있는 비관리자 사용자.
- 간단한 방화벽(UFW)이 활성화되어 실행 중입니다.
- Matrix, Element 및 Coturn을 가리키는 완전한 도메인 이름(FQDN). 우리는 세 가지 서비스에 대해 각각
matrix.example.com,element.example.com,coturn.example.com을 사용할 것입니다. - 모든 것이 업데이트되었는지 확인하십시오.
$ sudo apt update && sudo apt upgrade
1단계 - 방화벽 구성
패키지를 설치하기 전에 첫 번째 단계는 HTTP, HTTPS 및 Synapse의 포트를 열기 위해 방화벽을 구성하는 것입니다.
방화벽의 상태를 확인하십시오.
$ sudo ufw status
다음과 유사한 내용을 볼 수 있어야 합니다.
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
방화벽에서 HTTP, HTTPS 및 Synapse 포트를 엽니다.
$ sudo ufw allow 8448
$ sudo ufw allow http
$ sudo ufw allow https
확인을 위해 상태를 다시 확인하십시오.
$ sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
8448 ALLOW Anywhere
80/tcp ALLOW Anywhere
443 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
8448 (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
2단계 - Matrix Synapse 설치
Matrix GPG 키를 추가합니다.
$ sudo wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
Matrix APT 리포지토리를 추가합니다.
$ echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/matrix-org.list
시스템 리포지토리 목록을 업데이트합니다.
$ sudo apt update
Matrix Synapse를 설치합니다.
$ sudo apt install matrix-synapse-py3
설치 중에 서버 이름을 요청받게 되며, 이는 Matrix ID의 일부를 형성합니다. 여기에 Matrix 도메인 이름을 입력하십시오. 이는 홈 서버 주소로 작용합니다.
또한 Matrix에 홈 서버에 대한 익명 통계를 보내고 싶은지 여부를 묻는 질문을 받게 됩니다. 거부하려면 N을 입력하십시오.
이 설정은 나중에 /etc/matrix-synapse/conf.d/server_name.yaml 파일에서 변경할 수 있습니다.
Matrix Synapse의 서비스는 설치 중에 활성화되고 시작됩니다. 서비스 상태를 확인하십시오.
$ sudo systemctl status matrix-synapse
? matrix-synapse.service - Synapse Matrix homeserver
Loaded: loaded (/lib/systemd/system/matrix-synapse.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-09-26 09:38:38 UTC; 1min 19s ago
Process: 12926 ExecStartPre=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-key> Main PID: 12931 (python)
Tasks: 8 (limit: 2238)
Memory: 87.3M
CPU: 4.180s
CGroup: /system.slice/matrix-synapse.service
??12931 /opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/
Sep 26 09:38:36 matrix matrix-synapse[12926]: Generating signing key file /etc/matrix-synapse/homeserver.signing.key
Sep 26 09:38:37 matrix matrix-synapse[12931]: This server is configured to use 'matrix.org' as its trusted key server via the
Sep 26 09:38:37 matrix matrix-synapse[12931]: 'trusted_key_servers' config option. 'matrix.org' is a good choice for a key
Sep 26 09:38:37 matrix matrix-synapse[12931]: server since it is long-lived, stable and trusted. However, some admins may
Sep 26 09:38:37 matrix matrix-synapse[12931]: wish to use another server for this purpose.
Sep 26 09:38:37 matrix matrix-synapse[12931]: To suppress this warning and continue using 'matrix.org', admins should set
Sep 26 09:38:37 matrix matrix-synapse[12931]: 'suppress_key_server_warning' to 'true' in homeserver.yaml.
Sep 26 09:38:37 matrix matrix-synapse[12931]: --------------------------------------------------------------------------------
Sep 26 09:38:38 matrix matrix-synapse[12931]: Config is missing macaroon_secret_key
Sep 26 09:38:38 matrix systemd[1]: Started Synapse Matrix homeserver.
3단계 - PostgreSQL 설치 및 구성
PostgreSQL의 공식 APT 리포지토리를 사용하여 설치할 것입니다. PostgreSQL GPG 키를 추가하기 위해 다음 명령을 실행하십시오.
$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql-key.gpg >/dev/null
소스 목록에 APT 리포지토리를 추가합니다.
$ sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-key.gpg arch=amd64] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
시스템 리포지토리를 업데이트합니다.
$ sudo apt update
이제 다음 명령을 사용하여 PostgreSQL을 설치할 수 있습니다.
$ sudo apt install postgresql postgresql-contrib
PostgreSQL 서비스의 상태를 확인하십시오.
$ sudo systemctl status postgresql
? postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2022-09-26 09:41:36 UTC; 2min 14s ago
Process: 15586 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 15586 (code=exited, status=0/SUCCESS)
CPU: 1ms
Sep 26 09:41:36 matrix systemd[1]: Starting PostgreSQL RDBMS...
Sep 26 09:41:36 matrix systemd[1]: Finished PostgreSQL RDBMS.
서비스가 기본적으로 활성화되고 실행되고 있음을 확인할 수 있습니다.
postgres 시스템 계정으로 로그인합니다.
$ sudo -su postgres
새 데이터베이스 사용자와 PostgreSQL용 데이터베이스를 생성합니다.
$ createuser --pwprompt synapse
$ createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse synapse
postgres 계정에서 로그아웃합니다.
$ exit
4단계 - Nginx 설치
생산 환경에서는 Nginx 프록시를 사용하여 Synapse 서버를 실행하는 것이 좋습니다.
Ubuntu 22.04는 이전 버전의 Nginx를 제공합니다. 최신 버전을 설치하려면 공식 Nginx 리포지토리를 다운로드해야 합니다.
Nginx의 서명 키를 가져옵니다.
$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
Nginx의 안정적인 버전 리포지토리를 추가합니다.
$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
시스템 리포지토리를 업데이트합니다.
$ sudo apt update
Nginx를 설치합니다.
$ sudo apt install nginx
설치를 확인합니다.
$ nginx -v
nginx version: nginx/1.22.0
Nginx 서버를 시작합니다.
$ sudo systemctl start nginx
5단계 - SSL 설치
SSL 인증서를 생성하기 위해 Certbot을 설치해야 합니다. Ubuntu의 리포지토리를 사용하여 Certbot을 설치하거나 Snapd 도구를 사용하여 최신 버전을 가져올 수 있습니다. 우리는 Snapd 버전을 사용할 것입니다.
Ubuntu 22.04는 기본적으로 Snapd가 설치되어 있습니다. 다음 명령을 실행하여 Snapd 버전이 최신인지 확인하십시오.
$ sudo snap install core
$ sudo snap refresh core
Certbot을 설치합니다.
$ sudo snap install --classic certbot
Certbot 명령이 /usr/bin 디렉토리에서 실행될 수 있도록 심볼릭 링크를 생성하여 확인합니다.
$ sudo ln -s /snap/bin/certbot /usr/bin/certbot
SSL 인증서를 생성하기 위해 다음 명령을 실행합니다.
$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d matrix.example.com
위 명령은 서버의 /etc/letsencrypt/live/matrix.example.com 디렉토리에 인증서를 다운로드합니다.
Diffie-Hellman 그룹 인증서를 생성합니다.
$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096
SSL 갱신이 잘 작동하는지 확인하려면 프로세스의 드라이런을 수행합니다.
$ sudo certbot renew --dry-run
오류가 없으면 모든 설정이 완료된 것입니다. 인증서는 자동으로 갱신됩니다.
6단계 - Matrix Synapse 구성
Matrix 서버는 /etc/matrix-synapse/homeserver.yaml 파일을 통해 구성할 수 있지만, 업그레이드 후 덮어쓰기가 되므로 권장하지 않습니다. 생산 환경에서는 구성 파일을 /etc/matrix-synapse/conf.d 폴더에 배치해야 합니다.
Synapse 설치는 /etc/matrix-synapse/conf.d 폴더에 두 개의 구성 파일을 생성했습니다.
$ ls /etc/matrix-synapse/conf.d
report_stats.yaml server_name.yaml
데이터베이스용 새 구성 파일을 생성하고 편집을 위해 엽니다.
$ sudo nano /etc/matrix-synapse/conf.d/database.yaml
편집기에 다음 줄을 붙여넣습니다. your-password 필드를 3단계에서 생성한 PostgreSQL 사용자 비밀번호로 바꾸십시오. 데이터베이스를 다른 곳에 호스팅하는 경우 localhost를 서버의 IP 주소로 바꾸십시오.
database:
name: psycopg2
args:
user: synapse
password: 'your-password'
database: synapsedb
host: localhost
cp_min: 5
cp_max: 10
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
비공식 등록 키를 생성합니다. 이 키는 새로운 사용자를 등록할 수 있도록 허용하므로 보안이 필요합니다. 등록이 비활성화된 경우에도 가능합니다.
$ echo "registration_shared_secret: '$(cat /dev/urandom | tr -cd '[:alnum:]' | fold -w 256 | head -n 1)'" | sudo tee /etc/matrix-synapse/conf.d/registration_shared_secret.yaml
기본적으로 Synapse는 사용자가 온라인인지 여부를 표시하는 존재 지표를 활성화합니다. 이는 높은 CPU 사용량을 초래할 수 있으므로 비활성화할 수 있습니다. 동일한 파일에 대한 새 구성 파일을 생성합니다.
$ sudo nano /etc/matrix-synapse/conf.d/presence.yaml
편집기에 다음 줄을 붙여넣습니다.
presence:
enabled: false
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
변경 사항을 적용하기 위해 Synapse 서비스를 재시작합니다.
새 Matrix 사용자를 생성합니다. 사용자 이름과 비밀번호를 요청받게 됩니다. 우리가 생성하는 첫 번째 사용자이므로, 사용자를 관리자 권한으로 만들 것인지 묻는 질문에 yes를 입력합니다.
$ register_new_matrix_user -c /etc/matrix-synapse/conf.d/registration_shared_secret.yaml http://localhost:8008
New user localpart [navjot]: navjot
Password:
Confirm password:
Make admin [no]: yes
Sending registration request...
Success!
공식 등록을 열고 싶다면 새 구성 파일을 생성합니다.
$ sudo nano /etc/matrix-synapse/conf.d/registration.yaml
다음 줄을 붙여넣습니다.
enable_registration: true
기본적으로 Synapse는 이메일 확인 없이 등록을 허용하지 않습니다. 이메일 확인을 활성화하려면 다음 줄을 붙여넣습니다.
registrations_require_3pid:
- email
email:
smtp_host: mail.example.com
smtp_port: 587
# If mail server has no authentication, skip these 2 lines
smtp_user: '[email protected]'
smtp_pass: 'password'
# Optional, require encryption with STARTTLS
require_transport_security: true
app_name: 'HowtoForge Example Chat' # defines value for %(app)s in notif_from and email subject
notif_from: "%(app)s <[email protected]>"
이메일 확인을 비활성화하려면 대신 다음 줄을 붙여넣습니다.
enable_registration_without_verification: true
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
구성을 적용하기 위해 Synapse를 재시작합니다.
$ sudo systemctl restart matrix-synapse
7단계 - Nginx 구성
편집을 위해 /etc/nginx/nginx.conf 파일을 엽니다.
$ sudo nano /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.
server_names_hash_bucket_size 64;
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
편집을 위해 /etc/nginx/conf.d/synapse.conf 파일을 생성하고 엽니다.
$ sudo nano /etc/nginx/conf.d/synapse.conf
다음 코드를 붙여넣습니다.
# enforce HTTPS
server {
# Client port
listen 80;
listen [::]:80;
server_name matrix.example.com;
return 301 https://$host$request_uri;
}
server {
server_name matrix.example.com;
# Client port
listen 443 ssl http2;
listen [::]:443 ssl http2;
# Federation port
listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;
access_log /var/log/nginx/synapse.access.log;
error_log /var/log/nginx/synapse.error.log;
# TLS configuration
ssl_certificate /etc/letsencrypt/live/matrix.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/matrix.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/matrix.example.com/chain.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location ~ ^(/_matrix|/_synapse/client) {
proxy_pass http://localhost:8008;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# Nginx by default only allows file uploads up to 1M in size
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 50M;
}
}
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
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
Nginx 서비스를 재시작합니다.
$ sudo systemctl restart nginx
8단계 - Coturn 설치
음성 및 비디오 통화를 활성화하기 위해 NAT 주변에서 릴레이를 사용하는 TURN 서버를 설치해야 합니다. 이를 위해 Coturn 패키지를 설치할 것입니다. 이 기능이 필요하지 않다면 이 단계를 건너뛸 수 있습니다.
Ubuntu 22.04는 버그 문제로 인해 Coturn 패키지를 제공하지 않습니다. 그러나 비공식 리포지토리를 사용하여 Coturn을 설치하는 다른 방법이 있습니다. 선택적으로 Docker를 사용하여 Coturn을 설치할 수도 있지만, 이 튜토리얼의 범위를 벗어나므로 사용하지 않을 것입니다.
비공식 Coturn 리포지토리를 추가합니다.
$ sudo add-apt-repository ppa:ubuntuhandbook1/coturn
Coturn을 설치합니다.
$ sudo apt install coturn
TURN 및 UDP 포트를 엽니다.
$ sudo ufw allow 3478
$ sudo ufw allow 5349
$ sudo ufw allow 49152:65535/udp
Turn(turn.example.com)에 대한 SSL 인증서를 생성합니다.
$ sudo certbot certonly --nginx -d turn.example.com
인증 비밀을 생성하고 구성 파일에 저장합니다.
$ echo "static-auth-secret=$(cat /dev/urandom | tr -cd '[:alnum:]' | fold -w 256 | head -n 1)" | sudo tee /etc/turnserver.conf
편집을 위해 구성 파일을 엽니다.
$ sudo nano /etc/turnserver.conf
인증 비밀 아래에 다음 줄을 붙여넣습니다.
use-auth-secret
realm=turn.example.com
cert=/etc/letsencrypt/live/turn.example.com/fullchain.pem
pkey=/etc/letsencrypt/live/turn.example.com/privkey.pem
# VoIP is UDP, no need for TCP
no-tcp-relay
# Do not allow traffic to private IP ranges
deno-multicast-peers
denied-peer-ip=0.0.0.0-0.255.255.255
denied-peer-ip=10.0.0.0-10.255.255.255
denied-peer-ip=100.64.0.0-100.127.255.255
denied-peer-ip=127.0.0.0-127.255.255.255
denied-peer-ip=169.254.0.0-169.254.255.255
denied-peer-ip=172.16.0.0-172.31.255.255
denied-peer-ip=192.0.0.0-192.0.0.255
denied-peer-ip=192.0.2.0-192.0.2.255
denied-peer-ip=192.88.99.0-192.88.99.255
denied-peer-ip=192.168.0.0-192.168.255.255
denied-peer-ip=198.18.0.0-198.19.255.255
denied-peer-ip=198.51.100.0-198.51.100.255
denied-peer-ip=203.0.113.0-203.0.113.255
denied-peer-ip=240.0.0.0-255.255.255.255
denied-peer-ip=::1
denied-peer-ip=64:ff9b::-64:ff9b::ffff:ffff
deno-peer-ip=::ffff:0.0.0.0-::ffff:255.255.255.255
deno-peer-ip=100::-100::ffff:ffff:ffff:ffff
deno-peer-ip=2001::-2001:1ff:ffff:ffff:ffff:ffff:ffff:ffff
deno-peer-ip=2002::-2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff
deno-peer-ip=fc00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
deno-peer-ip=fe80::-febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff
# Limit number of sessions per user
user-quota=12
# Limit total number of sessions
total-quota=1200
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
구성을 적용하기 위해 Coturn을 재시작합니다.
$ sudo systemctl restart coturn
Coturn에 대한 새 Synapse 구성 파일을 생성합니다.
$ sudo nano /etc/matrix-synapse/conf.d/turn.yaml
다음 줄을 붙여넣습니다. turn_shared_secret 값을 static-auth-secret의 값으로 바꿉니다. /etc/turnserver.conf 파일에서 가져옵니다.
turn_uris: [ "turn:turn.example.com?transport=udp", "turn:turn.example.com?transport=tcp" ]
turn_shared_secret: 'static-auth-secret'
turn_user_lifetime: 86400000
turn_allow_guests: True
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
변경 사항을 적용하기 위해 Synapse를 재시작합니다.
$ sudo systemctl restart matrix-synapse
9단계 - Matrix 접근
Element의 웹 클라이언트를 사용하여 Matrix Chat에 접근할 수 있습니다. https://app.element.io에서 진행하십시오. 로그인 버튼을 클릭하여 진행합니다.

홈 서버 아래의 편집 링크를 클릭합니다. 홈 서버로 matrix.example.com을 입력합니다.

클라이언트가 홈 서버를 올바르게 감지하면 경계와 텍스트가 녹색으로 변하고, 그렇지 않으면 빨간색으로 표시됩니다. 계속을 클릭하여 진행합니다.

로그인 버튼을 클릭하여 로그인합니다. 안전하고 암호화된 백업을 생성하라는 요청을 받게 됩니다.

보안 문구 입력 옵션을 선택하여 로그인할 때마다 필요한 보안 문구를 생성합니다. 계속을 클릭하여 진행합니다.

보안 문구를 입력하고 계속 버튼을 클릭하여 진행합니다. 다음 화면에서 다시 확인하라는 요청을 받게 됩니다.

다시 문구를 입력하고 계속 버튼을 클릭하여 진행합니다.

보안 문구를 잊어버린 경우 사용할 수 있는 보안 키 세트를 받게 됩니다. 다운로드 버튼을 클릭하여 저장합니다.
계속 버튼을 클릭하여 진행합니다.

계정 비밀번호를 요청받습니다. 비밀번호를 입력하고 계속 버튼을 클릭하여 암호화된 백업 설정을 마칩니다.

위와 같이 Howtoforge라는 그룹 채팅룸을 생성했습니다.
10단계 - Element 설치
JSON 텍스트 프로세서를 설치하기 위해 jq 패키지를 설치합니다.
$ sudo apt install jq
Element를 위한 디렉토리를 생성합니다.
$ sudo mkdir -p /var/www/element
최신 Element 릴리스를 가져오기 위한 새 파일을 생성합니다.
$ sudo nano /var/www/element/update.sh
다음 줄을 추가합니다.
#!/bin/sh
set -e
install_location="/var/www/element"
latest="$(curl -s https://api.github.com/repos/vector-im/element-web/releases/latest | jq -r .tag_name)"
cd "$install_location"
[ ! -d "archive" ] && mkdir -p "archive"
[ -d "archive/element-${latest}" ] && rm -r "archive/element-${latest}"
[ -f "archive/element-${latest}.tar.gz" ] && rm "archive/element-${latest}.tar.gz"
wget "https://github.com/vector-im/element-web/releases/download/${latest}/element-${latest}.tar.gz" -P "archive"
tar xf "archive/element-${latest}.tar.gz" -C "archive"
[ -L "${install_location}/current" ] && rm "${install_location}/current"
ln -sf "${install_location}/archive/element-${latest}" "${install_location}/current"
ln -sf "${install_location}/config.json" "${install_location}/current/config.json"
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
파일을 실행 가능하게 만듭니다.
$ sudo chmod +x /var/www/element/update.sh
Element를 다운로드하기 위해 스크립트를 실행합니다.
$ sudo /var/www/element/update.sh
11단계 - Element 구성
같은 Element 구성 파일을 복사합니다.
$ sudo cp /var/www/element/current/config.sample.json /var/www/element/config.json
편집을 위해 구성 파일을 엽니다.
$ sudo nano /var/www/element/config.json
다음 줄을 찾습니다.
"m.homeserver": {
"base_url": "https://matrix-client.matrix.org",
"server_name": "matrix.org"
},
기본 Matrix 홈 서버 주소를 홈 서버로 변경하고 server_name 변수를 제거합니다.
"m.homeserver": {
"base_url": "https://matrix.example.com",
"server_name": "matrix.element.com"
},
웹사이트 제목에서 Element 대신 자신의 이름을 사용하려면 브랜드 이름을 변경합니다.
"brand": "Howtoforge Example Chat",
disable_guests 변수를 true로 설정하여 게스트가 Element를 사용하지 못하도록 합니다.
"disable_guests": true,
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
Element 클라이언트에 대한 SSL 인증서를 생성합니다.
$ sudo certbot certonly --nginx -d element.example.com
편집을 위해 /etc/nginx/conf.d/element.conf 파일을 생성하고 엽니다.
$ sudo nano /etc/nginx/conf.d/element.conf
다음 줄을 붙여넣습니다.
server {
listen 80;
listen [::]:80;
server_name element.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name element.example.com;
root /var/www/element/current;
index index.html;
access_log /var/log/nginx/element.access.log;
error_log /var/log/nginx/element.error.log;
add_header Referrer-Policy "strict-origin" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
# TLS configuration
ssl_certificate /etc/letsencrypt/live/element.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/element.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/element.example.com/chain.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
}
Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
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
Nginx 서비스를 재시작합니다.
$ sudo systemctl restart nginx
브라우저에서 https://element.example.com URL을 통해 Element 클라이언트에 접근할 수 있습니다. 로그인하면 앱 대시보드로 이동합니다.

결론
이로써 Nginx를 프록시 서버로 사용하여 Matrix Synapse 채팅 서버와 Coturn 및 Element 웹 클라이언트를 설치하는 튜토리얼이 마무리되었습니다. 질문이 있으시면 아래 댓글에 남겨주세요.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.