Synapse (Matrix) via dynDNS

that’s pretty perfect as we could easily enable Nginx to work as revers proxy for Matrix. Do following

nano /etc/nginx/sites-dietpi/matrix.conf

add following inside

    location /_matrix {
      proxy_pass http://127.0.0.1:8008;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      client_max_body_size 50M;
    }

    location /.well-known/matrix/server {
      return 200 '{"m.server": "your.ddns.spdns.de:443"}';
      add_header Content-Type application/json;
    }

    location /.well-known/matrix/client {
      return 200 '{"m.homeserver": {"base_url": "https://your.ddns.spdns.de"}}';
      add_header Content-Type application/json;
      add_header "Access-Control-Allow-Origin" *;
    }

save and exit the file. Restart Nginx now

systemctl restart nginx.service

Usually you should be able to reach Matrix via apps like Elemet. Custom URL would be simply your.ddns.spdns.de

This is based on this blog post https://decatec.de/home-server/matrix-synapse-auf-ubuntu-server-20-04-lts-mit-nginx-postgresql-und-lets-encrypt/#Virtueller_Host_fuer_Matrix_Synapse