Usage of dendrite-generate-config: -ci sane defaults for CI testing -db string The DB URI to use for all components if not SQLite files -server string The domain name of the server if not 'localhost'
location /.well-known/matrix/server { default_type application/json; return200'{ "m.server": "matrix.askk.cc:443" }'; } location /.well-known/matrix/client { # If your sever_name here doesn't match your matrix homeserver URL # (e.g. hostname.com as server_name and matrix.hostname.com as homeserver URL) default_type application/json; add_header Access-Control-Allow-Origin '*'; # 如果你 well-known server 与 homeserver 不同,就需要这行。 return200'{ "m.homeserver": { "base_url": "https://askk.cc" } }'; }
location /_matrix { proxy_pass http://monolith; }
listen443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/matrix.askk.cc/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/matrix.askk.cc/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot }
server { if ($host = matrix.askk.cc) { return301 https://$host$request_uri; } # managed by Certbot server_name matrix.askk.cc; listen80; return404; # managed by Certbot }
接下来安排 ssl, 首先安装 certbot
1
yay -S certbot
运行 certbot
1
sudo certbot
输入对应你域名的序号,回车。看到类似如下的输出就说明成功了
1 2 3 4 5 6 7 8 9 10 11 12
Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/askk.cc/fullchain.pem Key is saved at: /etc/letsencrypt/live/askk.cc/privkey.pem This certificate expires on2022-05-30. These files will be updated when the certificate renews.
Deploying certificate Successfully deployed certificate for askk.ccto /etc/nginx/conf.d/dendrite.conf Congratulations! You have successfully enabled HTTPS on https://askk.cc
NEXT STEPS: - The certificate will need tobe renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.
检查一下 dendrite.conf
1
cat nginx.conf
▶
下面的内容已经过期,`certbot` 会帮你加上那四行
你会发现末尾多了两行
1 2
ssl_certificate /etc/letsencrypt/live/askk.cc/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/askk.cc/privkey.pem; # managed by Certbot
#change IP to location of monolith server upstream monolith{ server127.0.0.1:8008; } server { listen443 ssl; # IPv4 listen [::]:443 ssl; # IPv6 server_name askk.cc;
location /.well-known/matrix/client { # If your sever_name here doesn't match your matrix homeserver URL # (e.g. hostname.com as server_name and matrix.hostname.com as homeserver URL) # add_header Access-Control-Allow-Origin '*'; return200'{ "m.homeserver": { "base_url": "https://askk.cc" } }'; }
location /_matrix { proxy_pass http://monolith; }
ssl_certificate /etc/letsencrypt/live/askk.cc/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/askk.cc/privkey.pem; # managed by Certbot ssl_dhparam /etc/letsencrypt/dhparams.pem; }
现在我们就算设置好了,重启 nginx 然后看下是否成功
1 2
sudo systemctl restart nginx sudo systemctl status nginx
如果有 绿色的 Active: active (running) 字样说明可以了。
使用不同于 homeserver 的 well known server
这件事的意义在于这里,由于我的 homeserver 叫 matrix.askk.cc , 所以在我的服务器注册的用户都会叫做 @xxx:matrix.askk.cc 这样其实不是很方便,我们也许希望用户叫做 @xxx:askk.cc. 但是我们可能已经把 askk.cc 拿来搭建网站了(443跟80已经被使用了。所以要使用其他的 well known server )
下面我们假设我的 homeserver 叫 askk.cc(即注册用户叫 @xxx:askk.cc), well known server 叫 matrix.askk.cc
如果你想要使用的 homeserver 与 well-know-server不同(说人话就是 matrix.org 的 well known server 是 matrix-federation.matrix.org)
你需要修改 /etc/dendrite/config.yaml,比如我希望 well know server 是 matrix.askk.cc
location /.well-known/matrix/client { # If your sever_name here doesn't match your matrix homeserver URL # (e.g. hostname.com as server_name and matrix.hostname.com as homeserver URL) default_type application/json; add_header Access-Control-Allow-Origin '*'; return200'{ "m.homeserver": { "base_url": "https://askk.cc" } }'; } # 其他部分 }
# The address that this appservice can use to connect to the homeserver. address:https://matrix.askk.cc # The domain of the homeserver (for MXIDs, etc). domain:askk.cc
改好配置文件之后,运行下面的命令,生成 registration.yaml
1 2
cd /etc/mautrix-telegram sudo -u mautrix-telegram python -m mautrix_telegram -g