meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
digital:server:matrixsynapse [2019/06/30 18:31]
natrius Switched Step 9 and 10
digital:server:matrixsynapse [2020/07/20 21:36]
natrius Changed example.com to homeserver.example according to RFC 2606 https://tools.ietf.org/html/rfc2606#section-2
Line 52: Line 52:
     sudo apt install matrix-synapse-py3     sudo apt install matrix-synapse-py3
  
-During the installation, it will ask you about the matrix server name - type in your domain ''example.com''. (We will not use ''matrix.example.com'', because we also don't use ''mail.example.com'' for our E-Mails. This will work with well.known, SRV-records and nginx.+During the installation, it will ask you about the matrix server name - type in your domain ''homeserver.example''. (We will not use ''matrix.homeserver.example'', because we also don't use ''mail.homeserver.example'' for our E-Mails. This will work with well.known, SRV-records and nginx.
  
 **Don't leave the hostname blank during setup.** **Don't leave the hostname blank during setup.**
Line 63: Line 63:
     sudo systemctl enable matrix-synapse.service     sudo systemctl enable matrix-synapse.service
  
-Synapse is now up and running using the default configuration on port '8008' and '8448'. Check the open ports using netstat command.+Synapse is now up and running using the default configuration on port '8008' and '8448'. Check the open ports using ss (former netstatcommand.
  
-    sudo ss -plntu+    ss -plntu
  
-#### Set up well.known+#### Set up .well-known
  
 On your webserver a file at ''%%/.well-known/matrix/server%%'' has to be set up with the following content  On your webserver a file at ''%%/.well-known/matrix/server%%'' has to be set up with the following content 
Line 73: Line 73:
 <code> <code>
 { {
-    "m.server": "synapse.example.com:443"+    "m.server": "synapse.homeserver.example:443"
 } }
 </code> </code>
  
-Where ''/'' is the root of your webserver. So if you navigate to ''https://example.com/.well-known/matrix.server'' it may try to download the ''server'' file or show it directly+Where ''/'' is the root of your webserver. So if you navigate to ''https://homeserver.example/.well-known/matrix/server'' it may try to download the ''server'' file or show it directly.
- +
-#### Set up SRV +
- +
-By setting an SRV record in your DNS provider, it is possible to tell other matrix servers where to connect to the server, pointing them to the correct hostname and port, in this example the default port (8448) is still used: +
- +
-<code> +
-_matrix._tcp.example.com. 3600 IN SRV 10 5 443 synapse.example.com. +
-</code> +
- +
-There is still an A record needed, pointing to the IP-addess of synapse on the subdomain (matrix.example.com). This way others can add your user with ''@user:example.com'' instead of ''@user:matrix.example.com''.+
  
 ### Step 3 - Configure Synapse ### Step 3 - Configure Synapse
Line 131: Line 121:
 Check the homeserver service with the following command Check the homeserver service with the following command
  
-    sudo ss -plntu+    ss -plntu
  
 You will get the Synapse service is now on the local IP address. And we have completed the Synapse installation and configuration. You will get the Synapse service is now on the local IP address. And we have completed the Synapse installation and configuration.
Line 150: Line 140:
     sudo apt-get install certbot python-certbot-nginx     sudo apt-get install certbot python-certbot-nginx
  
-Generate the SSL certificate files for the matrix domain name ''example.com'' using the certbot command as shown below.+Generate the SSL certificate files for the matrix domain name ''homeserver.example'' using the certbot command as shown below.
  
     sudo certbot --nginx     sudo certbot --nginx
  
-The Letsencrypt tool will generate SSL certificate files by running the 'standalone' temporary web server for verification. When it's complete, you will get the information that its done and where the certificates are stored. Usally the SSL certificate files for the Synapse domain name ''example.com'' are generated inside the ''/etc/letsencrypt/live/'' directory.+The Letsencrypt tool will generate SSL certificate files by running the 'standalone' temporary web server for verification. When it's complete, you will get the information that its done and where the certificates are stored. Usally the SSL certificate files for the Synapse domain name ''homeserver.example'' are generated inside the ''/etc/letsencrypt/live/'' directory.
  
 <code> <code>
Line 161: Line 151:
 Obtaining a new certificate Obtaining a new certificate
 Performing the following challenges: Performing the following challenges:
-http-01 challenge for example.com+http-01 challenge for homeserver.example
 Waiting for verification... Waiting for verification...
 Cleaning up challenges Cleaning up challenges
Line 167: Line 157:
 IMPORTANT NOTES: IMPORTANT NOTES:
  - Congratulations! Your certificate and chain have been saved at:  - Congratulations! Your certificate and chain have been saved at:
-   /etc/letsencrypt/live/example.com/fullchain.pem+   /etc/letsencrypt/live/homeserver.example/fullchain.pem
    Your key file has been saved at:    Your key file has been saved at:
-   /etc/letsencrypt/live/example.com/privkey.pem+   /etc/letsencrypt/live/homeserver.example/privkey.pem
    Your cert will expire on 2019-03-03. To obtain a new or tweaked    Your cert will expire on 2019-03-03. To obtain a new or tweaked
    version of this certificate in the future, simply run certbot    version of this certificate in the future, simply run certbot
Line 200: Line 190:
     sudo systemctl enable nginx.service     sudo systemctl enable nginx.service
  
-Next, we will create a new virtual host configuration for the domain name ''example.com''. Go to the '/etc/nginx' configuration directory and create a new virtual host file 'matrix'.+Next, we will create a new virtual host configuration for the domain name ''homeserver.example''. Go to the '/etc/nginx' configuration directory and create a new virtual host file 'matrix'.
  
 <code>sudoedit /etc/nginx/sites-available/matrix</code> <code>sudoedit /etc/nginx/sites-available/matrix</code>
  
-Paste the following configuration there, changing the domain ''example.com'' to your own:+Paste the following configuration there, changing the domain ''homeserver.example'' to your own:
  
 <code> <code>
 server { server {
        listen 80;        listen 80;
-       server_name example.com;+       server_name homeserver.example;
        return 301 https://$server_name$request_uri;        return 301 https://$server_name$request_uri;
 } }
Line 216: Line 206:
     listen 443 ssl;     listen 443 ssl;
     listen [::]:443 ssl;     listen [::]:443 ssl;
-    server_name example.com;+    server_name homeserver.example;
  
-    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; +    ssl_certificate /etc/letsencrypt/live/homeserver.example/fullchain.pem; 
-    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;+    ssl_certificate_key /etc/letsencrypt/live/homeserver.example/privkey.pem;
  
     # If you don't wanna serve a site, comment this out     # If you don't wanna serve a site, comment this out
Line 230: Line 220:
     }     }
     location /.well-known/matrix/server {     location /.well-known/matrix/server {
-      return 200 '{"m.server": "example.com:443"}';+      return 200 '{"m.server": "homeserver.example:443"}';
       add_header Content-Type application/json;       add_header Content-Type application/json;
     }     }
     location /.well-known/matrix/client {     location /.well-known/matrix/client {
-      return 200 '{"m.homeserver": {"base_url": "https://example.com"},"m.identity_server": {"base_url": "https://vector.im"}}';+      return 200 '{"m.homeserver": {"base_url": "https://homeserver.example"},"m.identity_server": {"base_url": "https://vector.im"}}';
       add_header Content-Type application/json;       add_header Content-Type application/json;
       add_header "Access-Control-Allow-Origin" *;       add_header "Access-Control-Allow-Origin" *;
Line 301: Line 291:
  
   * ''user'' is in this case ''synapse_user''   * ''user'' is in this case ''synapse_user''
-  * ''Database'' should be the above created db, example ''"databse: synpase"''+  * ''Database'' should be the above created db, example ''synapse''
   * ''Host'' is the postgre hostname, usally ''/var/run/postgresql/'' or ''127.0.0.1''   * ''Host'' is the postgre hostname, usally ''/var/run/postgresql/'' or ''127.0.0.1''
  
Line 312: Line 302:
 ### Migrating from SQlite to PostgreSQL ### Migrating from SQlite to PostgreSQL
  
-There is no need for this if you have nothing done yet with synapse, otherwise, please refer to https://github.com/matrix-org/synapse/blob/master/docs/postgres.rst+Assuming you already followed step 6, there is no need for a migration. If you already used your Synapse and want to migrate, please refer to https://github.com/matrix-org/synapse/blob/master/docs/postgres.md
  
 ### Step 7 - Setup UFW Firewall ### Step 7 - Setup UFW Firewall
Line 338: Line 328:
 ### Step 9 - Testing ### Step 9 - Testing
  
-If you have used Riot with the desktop application before you may not want to log out, so it is better to go to [[https://riot.im/app/]] and press "Launch now". If you have used the web client before, download the Riot desktop application, install it and open the Riot software. With both you will get the Matrix login page now. Type the matrix username and password, then choose the 'Custom server' option and type the domain name from your server ''example.com'' in. Click the ''Sign In'' button and you will get to the Riot Dashboard.+If you have used Riot with the desktop application before you may not want to log out, so it is better to go to [[https://riot.im/app/]] and press "Launch now". If you have used the web client before, download the Riot desktop application, install it and open the Riot software. With both you will get the Matrix login page now. Type the matrix username and password, then choose the 'Custom server' option and type the domain name from your server ''homeserver.example'' in. Click the ''Sign In'' button and you will get to the Riot Dashboard.
  
 The Synapse homeserver is up and running under the Nginx reverse proxy HTTPS connection, and the user is now logged in to the Synapse homeserver using the Riot application. The Synapse homeserver is up and running under the Nginx reverse proxy HTTPS connection, and the user is now logged in to the Synapse homeserver using the Riot application.
Line 344: Line 334:
 If you need two instances of riot instead, you can start it with argument, refer to [[digital:software:riotim|Riot.im]]. If you need two instances of riot instead, you can start it with argument, refer to [[digital:software:riotim|Riot.im]].
  
-For another way to test it, go to ''https://example.com/_matrix/client/versions'' and the output should look like the following:+For another way to test it, go to ''https://homeserver.example/_matrix/static/'' and you will be presented with a ''**It works! Synapse is running**'' screen or go to ''https://homeserver.example/_matrix/client/versions'' and the output should look like the following:
  
 <code xml> <code xml>
Line 423: Line 413:
 ### Whats my version ### Whats my version
  
-  * https://example.com/_matrix/federation/v1/version+  * https://homeserver.example/_matrix/federation/v1/version
  
 ### Location of logs ### Location of logs