Setup Matrix Synapse Home Server with unlimited logins and unlimited message sending in channels.
1.1K
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER
# create working directories
sudo mkdir ~/docker/matrix-synapse -p && sudo mkdir ~/docker/postgresql -p
# set owner of docker directory
sudo chown "$USER":"$USER" ~/docker -R
# run the postgesql docker container
docker run -d --name postgres -e POSTGRES_USER=matrix_synapse_rw -e POSTGRES_PASSWORD=m@trix! -e POSTGRES_DB=matrix_synapse -e LC_COLLATE='C' -e LC_CTYPE='C' -e POSTGRES_INITDB_ARGS="--encoding=UTF-8" -v ~/docker/postgresql:/var/lib/postgresql/data --restart=unless-stopped postgres:latest
# generate synapse homeserver.yaml
docker run -it --rm -v ~/docker/matrix-synapse:/data -e SYNAPSE_SERVER_NAME=my.matrix.host -e SYNAPSE_REPORT_STATS=no singhragvendra503/matrix_server:latest generate
# edit the homeserver.yaml file
sudo nano ~/docker/matrix-synapse/homeserver.yaml
Press CTRL+W and search for name: server_name
server_name: "YOUR.MATRIX.DNS"
Press CTRL+W and search for name: sqlite3
Comment out the sqlite database parameters by adding a # to the beginning of each of the lines
Add the following database connection below the commented out lines to connect to the Postgres container:
database:
name: psycopg2
txn_limit: 10000
args:
user: matrix_synapse_rw
password: m@trix!
database: matrix_synapse
host: postgres
port: 5432
cp_min: 5
cp_max: 10
Add the following line at the bottom of the file
suppress_key_server_warning: true
# generate a random string
RANDOMSTRING=$(openssl rand -base64 30)
# write the random string as registration_shared_secret
echo "registration_shared_secret: $RANDOMSTRING" | sudo tee -a ~/docker/matrix-synapse/homeserver.yaml > /dev/null
# run the matrix synapse container
docker run -d --name matrix-synapse --link postgres -v ~/docker/matrix-synapse:/data -p 8008:8008 --restart=unless-stopped singhragvendra503/matrix_server:latest
# create a new synapse user
docker exec -it matrix-synapse register_new_matrix_user http://DNSorIP:8008 -c /data/homeserver.yaml
cat ~/docker/matrix-synapse/homeserver.yaml
# Configuration file for Synapse.
#
# This is a YAML file: see [1] for a quick introduction. Note in particular
# that *indentation is important*: all the elements of a list or dictionary
# should have the same indentation.
#
# [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
#
# For more information on how to configure Synapse, including a complete accounting of
# each option, go to docs/usage/configuration/config_documentation.md or
# https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html
server_name: "my.matrix.host"
pid_file: /data/homeserver.pid
listeners:
- port: 8008
tls: false
type: http
x_forwarded: true
resources:
- names: [client, federation]
compress: false
database:
name: psycopg2
txn_limit: 10000
args:
user: matrix_synapse_rw
password: m@trix!
database: matrix_synapse
host: postgres
port: 5432
cp_min: 5
cp_max: 10
log_config: "/data/my.matrix.host.log.config"
media_store_path: /data/media_store
registration_shared_secret: "ztgCve+jU.vap#p80^iyAKM-4a=wKWIVo:@o_exbj~9N,5LFO^"
report_stats: false
macaroon_secret_key: "8T.Dl*nBNL:Uenq5HqA4D3OCbyfWZ4PMr9F-Vmfx;C&SHp+LJ-"
form_secret: "+0hOU8._jBg+IZHvW-,ezmjbziYOI~NI~,&S4U:tArA1x2#J~^"
signing_key_path: "/data/my.matrix.host.signing.key"
trusted_key_servers:
- server_name: "matrix.org"
# Add these line manually for increase message sending limit and login limit
rc_messages_per_second: 10.0
rc_message_burst_count: 100.0
rc_login:
address:
per_second: 1
burst_count: 500
account:
per_second: 0.18
burst_count: 4
failed_attempts:
per_second: 0.19
burst_count: 7
# vim:ft=yaml
suppress_key_server_warning: true # Add these line manually
registration_shared_secret: VbX+vJV2KbCuSpLg3COWD/GINqNZo4ADHKw2ZaIp #This is add when you generate token
# Add these line manually
enable_registration_without_verification: true
enable_registration: true
curl -XPOST -d '{"username":"example", "password":"wordpass", "auth": {"type":"m.login.dummy"}}' "http://34.170.94.25:8008:8008/_matrix/client/r0/register"
{"user_id":"@example:my.matrix.host","home_server":"my.matrix.host","access_token":"syt_ZXhhbXBsZQ_DPzGvfEQGmJcatJJOBxP_0OaoZ0","device_id":"HAXWLFVOQL"}
curl -XPOST -d '{"type":"m.login.password", "user":"example", "password":"wordpass"}' "http://34.170.94.25:8008/_matrix/client/r0/login"
{"user_id":"@example:my.matrix.host","access_token":"syt_ZXhhbXBsZQ_STmlBUcgdzcgVvDfEWXF_4WkbFI","home_server":"my.matrix.host","device_id":"HAXWLFVOQL"}
#!/bin/bash
for ((i=0; i<100; i++)); do
curl -XPOST -d '{"type":"m.login.password", "user":"example", "password":"wordpass"}' "http://34.170.94.25:8008/_matrix/client/r0/login"
done
curl -XPOST -d '{"room_alias_name":"demo"}' "http://34.170.94.25:8008/_matrix/client/r0/createRoom?access_token=syt_ZXhhbXBsZQ_STmlBUcgdzcgVvDfEWXF_4WkbFI"
{"room_id":"!sudPlwVbHmLYkpFKuF:my.matrix.host"}
curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "http://34.170.94.25:8008/_matrix/client/r0/rooms/%21sudPlwVbHmLYkpFKuF:my.matrix.host/send/m.room.message?access_token=syt_ZXhhbXBsZQ_STmlBUcgdzcgVvDfEWXF_4WkbFI"
{"event_id":"$0E6oy93YGzbWair0GUT2poaWFITTzm4sBX2mgYci2Po"}
#!/bin/bash
for ((i=0; i<2000; i++)); do
curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "http://34.170.94.25:8008/_matrix/client/r0/rooms/%21sudPlwVbHmLYkpFKuF:my.matrix.host/send/m.room.message?access_token=syt_ZXhhbXBsZQ_STmlBUcgdzcgVvDfEWXF_4WkbFI"
done
Content type
Image
Digest
sha256:d5507b5c6…
Size
130.5 MB
Last updated
about 3 years ago
docker pull singhragvendra503/matrix_server