├── .gitignore ├── data-template ├── nginx │ ├── www │ │ └── .well-known │ │ │ ├── matrix │ │ │ ├── server │ │ │ ├── support │ │ │ └── client │ │ │ └── element │ │ │ └── element.json │ └── conf.d │ │ ├── include │ │ └── ssl.conf │ │ └── app.conf ├── synapse │ ├── workers │ │ ├── synapse-federation-sender-1.yaml │ │ └── synapse-generic-worker-1.yaml │ ├── log.config │ └── homeserver.yaml ├── element-call │ └── config.json ├── element-web │ └── config.json ├── mas │ └── config.yaml └── livekit │ └── config.yaml ├── init ├── Dockerfile ├── generate-synapse-secrets.sh ├── generate-mas-secrets.sh └── init.sh ├── scripts ├── livekit-jwt-entrypoint.sh └── create-multiple-postgresql-databases.sh ├── .env-sample ├── setup.sh ├── init-letsencrypt.sh ├── README.md ├── compose.yml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | **/.DS_Store 3 | 4 | .env 5 | .env.orig 6 | data 7 | secrets 8 | -------------------------------------------------------------------------------- /data-template/nginx/www/.well-known/matrix/server: -------------------------------------------------------------------------------- 1 | { 2 | "m.server": "${HOMESERVER_FQDN}:443" 3 | } 4 | -------------------------------------------------------------------------------- /data-template/nginx/www/.well-known/element/element.json: -------------------------------------------------------------------------------- 1 | { 2 | "call": { 3 | "widget_url": "https://${ELEMENT_CALL_FQDN}" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /init/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | # TODO: check this doesn't reinstall yq on every launch and use a builder if necessary 4 | RUN apk update && apk add yq bash envsubst 5 | -------------------------------------------------------------------------------- /data-template/synapse/workers/synapse-federation-sender-1.yaml: -------------------------------------------------------------------------------- 1 | ${CONFIG_HEADER} 2 | 3 | worker_app: synapse.app.federation_sender 4 | worker_name: synapse-federation-sender-1 5 | 6 | worker_log_config: /data/log.config 7 | -------------------------------------------------------------------------------- /data-template/nginx/www/.well-known/matrix/support: -------------------------------------------------------------------------------- 1 | { 2 | "support_page": "https://matrix.org/contact/", 3 | "contacts": [ 4 | { "role": "m.role.admin", "email_address": "${ABUSE_SUPPORT_EMAIL}" }, 5 | { "role": "m.role.security", "email_address": "${SECURITY_SUPPORT_EMAIL}" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /data-template/nginx/conf.d/include/ssl.conf: -------------------------------------------------------------------------------- 1 | listen 443 ssl; 2 | listen [::]:443 ssl; 3 | 4 | ssl_certificate /etc/nginx/ssl/fullchain.pem; 5 | ssl_certificate_key /etc/nginx/ssl/privkey.pem; 6 | 7 | include /etc/nginx/ssl/options-ssl-nginx.conf; 8 | ssl_dhparam /etc/nginx/ssl/ssl-dhparams.pem; 9 | -------------------------------------------------------------------------------- /scripts/livekit-jwt-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # launch lk-jwt-service with secrets from disk 4 | 5 | export LK_JWT_PORT=8080 6 | export LIVEKIT_URL=wss://${LIVEKIT_FQDN} 7 | export LIVEKIT_KEY=$( 33 | MAS_EMAIL_REPLY_TO=Matrix Authentication Service 34 | 35 | # This should be the public IP of your $LIVEKIT_FQDN. 36 | # If livekit doesn't work, double-check this. 37 | LIVEKIT_NODE_IP=127.0.0.1 38 | 39 | COUNTRY=GB 40 | 41 | # as a convenience for creating /etc/hosts 42 | DOMAINS="$DOMAIN $HOMESERVER_FQDN $MAS_FQDN $ELEMENT_WEB_FQDN $ELEMENT_CALL_FQDN $LIVEKIT_FQDN $LIVEKIT_JWT_FQDN" 43 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | #set -x 5 | 6 | # set up data & secrets dir with the right ownerships in the default location 7 | # to stop docker autocreating them with random owners. 8 | # originally these were checked into the git repo, but that's pretty ugly, so doing it here instead. 9 | mkdir -p data/{element-{web,call},livekit,mas,nginx/{ssl,www,conf.d},postgres,synapse} 10 | mkdir -p secrets/{livekit,postgres,synapse} 11 | 12 | # create blank secrets to avoid docker creating empty directories in the host 13 | touch secrets/livekit/livekit_{api,secret}_key \ 14 | secrets/postgres/postgres_password \ 15 | secrets/synapse/signing.key 16 | 17 | # grab an env if we don't have one already 18 | if [[ ! -e .env ]]; then 19 | cp .env-sample .env 20 | 21 | sed -ri.orig "s/^USER_ID=/USER_ID=$(id -u)/" .env 22 | sed -ri.orig "s/^GROUP_ID=/GROUP_ID=$(id -g)/" .env 23 | 24 | read -p "Enter base domain name (e.g. example.com): " DOMAIN 25 | sed -ri.orig "s/example.com/$DOMAIN/" .env 26 | 27 | # try to guess your livekit IP 28 | if [ -x "$(command -v getent)" ]; then 29 | NODE_IP=`getent hosts livekit.$DOMAIN | cut -d' ' -f1` 30 | if ! [ -z "$NODE_IP" ]; then 31 | sed -ri.orig "s/LIVEKIT_NODE_IP=127.0.0.1/LIVEKIT_NODE_IP=$NODE_IP/" .env 32 | fi 33 | fi 34 | 35 | # SSL setup 36 | read -p "Use local mkcert CA for SSL? [y/n] " use_mkcert 37 | if [[ "$use_mkcert" =~ ^[Yy]$ ]]; then 38 | if ! [ -x "$(command -v mkcert)" ]; then 39 | echo "Please install mkcert from brew/apt/yum etc" 40 | exit 41 | fi 42 | mkcert -install 43 | mkcert $DOMAIN '*.'$DOMAIN 44 | mkdir -p data/ssl 45 | mv ${DOMAIN}+1.pem data/ssl/fullchain.pem 46 | mv ${DOMAIN}+1-key.pem data/ssl/privkey.pem 47 | cp "$(mkcert -CAROOT)"/rootCA.pem data/ssl/ca-certificates.crt 48 | # borrow letsencrypt's SSL config 49 | curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "data/ssl/options-ssl-nginx.conf" 50 | curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "data/ssl/ssl-dhparams.pem" 51 | success=true 52 | else 53 | read -p "Use letsencrypt for SSL? [y/n] " use_letsencrypt 54 | if [[ "$use_letsencrypt" =~ ^[Yy]$ ]]; then 55 | mkdir -p data/ssl 56 | touch data/ssl/ca-certificates.crt # will get overwritten by init-letsencrypt.sh 57 | source ./init-letsencrypt.sh 58 | success=true 59 | else 60 | echo "Please put a valid {privkey,fullchain}.pem and ca-certificates.crt into data/ssl/" 61 | fi 62 | fi 63 | else 64 | echo ".env already exists; move it out of the way first to re-setup" 65 | fi 66 | 67 | if ! [ -z "$success" ]; then 68 | echo ".env and SSL configured; you can now docker compose up" 69 | fi 70 | -------------------------------------------------------------------------------- /data-template/mas/config.yaml: -------------------------------------------------------------------------------- 1 | ${CONFIG_HEADER} 2 | 3 | http: 4 | listeners: 5 | - name: web 6 | resources: 7 | - name: discovery 8 | - name: human 9 | - name: oauth 10 | - name: compat 11 | - name: graphql 12 | - name: assets 13 | binds: 14 | - address: '[::]:8080' 15 | proxy_protocol: false 16 | - name: internal 17 | resources: 18 | - name: health 19 | binds: 20 | - host: localhost 21 | port: 8081 22 | proxy_protocol: false 23 | trusted_proxies: 24 | - 192.168.0.0/16 25 | - 172.16.0.0/12 26 | - 10.0.0.0/10 27 | - 127.0.0.1/8 28 | - fd00::/8 29 | - ::1/128 30 | public_base: https://${MAS_FQDN}/ 31 | issuer: https://${DOMAIN}/ 32 | database: 33 | host: postgres 34 | database: mas 35 | username: matrix 36 | password: ${SECRETS_POSTGRES_PASSWORD} 37 | max_connections: 10 38 | min_connections: 0 39 | connect_timeout: 30 40 | idle_timeout: 600 41 | max_lifetime: 1800 42 | email: 43 | from: '${MAS_EMAIL_FROM}' 44 | reply_to: '${MAS_EMAIL_REPLY_TO}' 45 | transport: smtp 46 | mode: plain 47 | hostname: ${SMTP_HOST} 48 | port: ${SMTP_PORT} 49 | ${SECRETS_MAS_SECRETS} 50 | passwords: 51 | enabled: true 52 | schemes: 53 | - version: 1 54 | algorithm: argon2id 55 | minimum_complexity: 3 56 | matrix: 57 | homeserver: ${DOMAIN} 58 | secret: '${SECRETS_MAS_MATRIX_SECRET}' 59 | endpoint: https://${HOMESERVER_FQDN}/ 60 | 61 | # please keep config above this point as close as possible to the original generated config 62 | # so that upstream generated config changes can be detected 63 | 64 | # these taken from midhun's quick-mas-setup 65 | clients: 66 | - client_id: ${MAS_CLIENT_ID} 67 | client_auth_method: client_secret_basic 68 | client_secret: '${SECRETS_MAS_CLIENT_SECRET}' 69 | 70 | templates: 71 | path: /usr/local/share/mas-cli/templates/ 72 | assets_manifest: /usr/local/share/mas-cli/manifest.json 73 | translations_path: /usr/local/share/mas-cli/translations/ 74 | 75 | policy: 76 | wasm_module: /usr/local/share/mas-cli/policy.wasm 77 | client_registration_entrypoint: client_registration/violation 78 | register_entrypoint: register/violation 79 | authorization_grant_entrypoint: authorization_grant/violation 80 | password_entrypoint: password/violation 81 | email_entrypoint: email/violation 82 | data: 83 | client_registration: 84 | allow_insecure_uris: true # allow non-SSL and localhost URIs 85 | allow_missing_contacts: true # EW doesn't have contacts at this time 86 | admin_users: 87 | - admin 88 | 89 | account: 90 | password_registration_enabled: false 91 | 92 | branding: 93 | service_name: null 94 | policy_uri: null 95 | tos_uri: null 96 | imprint: null 97 | logo_uri: null 98 | 99 | upstream_oauth2: 100 | providers: [] 101 | 102 | experimental: 103 | access_token_ttl: 86400 104 | compat_token_ttl: 86400 105 | -------------------------------------------------------------------------------- /data-template/synapse/log.config: -------------------------------------------------------------------------------- 1 | ${CONFIG_HEADER} 2 | 3 | # Log configuration for Synapse. 4 | # 5 | # This is a YAML file containing a standard Python logging configuration 6 | # dictionary. See [1] for details on the valid settings. 7 | # 8 | # Synapse also supports structured logging for machine readable logs which can 9 | # be ingested by ELK stacks. See [2] for details. 10 | # 11 | # [1]: https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema 12 | # [2]: https://element-hq.github.io/synapse/latest/structured_logging.html 13 | 14 | version: 1 15 | 16 | formatters: 17 | precise: 18 | format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' 19 | 20 | handlers: 21 | file: 22 | class: logging.handlers.TimedRotatingFileHandler 23 | formatter: precise 24 | filename: /data/homeserver.log 25 | when: midnight 26 | backupCount: 3 # Does not include the current log file. 27 | encoding: utf8 28 | 29 | # Default to buffering writes to log file for efficiency. 30 | # WARNING/ERROR logs will still be flushed immediately, but there will be a 31 | # delay (of up to `period` seconds, or until the buffer is full with 32 | # `capacity` messages) before INFO/DEBUG logs get written. 33 | buffer: 34 | class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler 35 | target: file 36 | 37 | # The capacity is the maximum number of log lines that are buffered 38 | # before being written to disk. Increasing this will lead to better 39 | # performance, at the expensive of it taking longer for log lines to 40 | # be written to disk. 41 | # This parameter is required. 42 | capacity: 10 43 | 44 | # Logs with a level at or above the flush level will cause the buffer to 45 | # be flushed immediately. 46 | # Default value: 40 (ERROR) 47 | # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) 48 | flushLevel: 30 # Flush immediately for WARNING logs and higher 49 | 50 | # The period of time, in seconds, between forced flushes. 51 | # Messages will not be delayed for longer than this time. 52 | # Default value: 5 seconds 53 | period: 5 54 | 55 | # A handler that writes logs to stderr. Unused by default, but can be used 56 | # instead of "buffer" and "file" in the logger handlers. 57 | console: 58 | class: logging.StreamHandler 59 | formatter: precise 60 | 61 | loggers: 62 | synapse.storage.SQL: 63 | # beware: increasing this to DEBUG will make synapse log sensitive 64 | # information such as access tokens. 65 | level: INFO 66 | 67 | root: 68 | level: INFO 69 | 70 | # Write logs to the `buffer` handler, which will buffer them together in memory, 71 | # then write them to a file. 72 | # 73 | # Replace "buffer" with "console" to log to stderr instead. 74 | # 75 | handlers: [console] 76 | 77 | disable_existing_loggers: false 78 | -------------------------------------------------------------------------------- /init-letsencrypt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # taken from https://raw.githubusercontent.com/wmnnd/nginx-certbot/refs/heads/master/init-letsencrypt.sh 4 | 5 | #set -x 6 | 7 | if ! [ -x "$(command -v docker)" ]; then 8 | echo 'Error: docker is not installed.' >&2 9 | exit 1 10 | fi 11 | 12 | source .env 13 | domains=($DOMAINS) 14 | rsa_key_size=4096 15 | data_path="./data/certbot" 16 | read -p "admin email address for letsencrypt: " email 17 | staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits 18 | 19 | if [ -d "$data_path" ]; then 20 | read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision 21 | if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then 22 | exit 23 | fi 24 | fi 25 | 26 | if [ ! -e "data/ssl/options-ssl-nginx.conf" ] || [ ! -e "data/ssl/ssl-dhparams.pem" ]; then 27 | echo "### Downloading recommended TLS parameters ..." 28 | mkdir -p "$data_path/conf" 29 | curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "data/ssl/options-ssl-nginx.conf" 30 | curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "data/ssl/ssl-dhparams.pem" 31 | echo 32 | fi 33 | 34 | # echo "### Creating dummy certificate for $domains ..." 35 | # # N.B. in bash, $domains will return the first value of the array in string context, so this is not a bug: 36 | # mkdir -p "$data_path/conf/live/$domains" 37 | # path="/etc/letsencrypt/live/$domains" 38 | # docker compose run --rm --entrypoint "\ 39 | # openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\ 40 | # -keyout '$path/privkey.pem' \ 41 | # -out '$path/fullchain.pem' \ 42 | # -subj '/CN=localhost'; \ 43 | # cp /etc/ssl/certs/ca-certificates.crt '$path'" certbot 44 | # echo 45 | # 46 | # echo "### Starting nginx ..." 47 | # docker compose up --force-recreate -d nginx 48 | # echo 49 | # 50 | # exit 51 | # 52 | # echo "### Deleting dummy certificate for $domains ..." 53 | # docker compose run --rm --entrypoint "\ 54 | # rm -Rf /etc/letsencrypt/live/$domains && \ 55 | # rm -Rf /etc/letsencrypt/archive/$domains && \ 56 | # rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot 57 | # echo 58 | 59 | echo "### Requesting Let's Encrypt certificate for $domains ..." 60 | #Join $domains to -d args 61 | domain_args="" 62 | for domain in "${domains[@]}"; do 63 | domain_args="$domain_args -d $domain" 64 | done 65 | 66 | # Select appropriate email arg 67 | case "$email" in 68 | "") email_arg="--register-unsafely-without-email" ;; 69 | *) email_arg="--email $email" ;; 70 | esac 71 | 72 | # Enable staging mode if needed 73 | if [ $staging != "0" ]; then staging_arg="--staging"; fi 74 | 75 | docker compose run -p 80:80 --rm --entrypoint " \ 76 | sh -c \"certbot certonly --standalone \ 77 | $staging_arg \ 78 | $email_arg \ 79 | $domain_args \ 80 | --rsa-key-size $rsa_key_size \ 81 | --agree-tos \ 82 | --force-renewal; 83 | cp /etc/letsencrypt/live/$domains/*.pem /data/ssl; \ 84 | cp /etc/ssl/certs/ca-certificates.crt /data/ssl; \ 85 | chown -R $USER_ID:$GROUP_ID /data/ssl; \ 86 | \"" certbot 87 | echo 88 | 89 | # echo "### Reloading nginx ..." 90 | # docker compose exec nginx nginx -s reload 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # element-docker-demo 2 | 3 | element-docker-demo is a minimal example of how to rapidly stand up a Matrix 2.0 stack on macOS or Linux using Docker, 4 | featuring: 5 | 6 | * Element Web 7 | * Element Call 8 | * Synapse 9 | * Matrix Authentication Service 10 | * LiveKit 11 | * Postgres 12 | * nginx + letsencrypt / mkcert for TLS. 13 | 14 | This is **not** intended for serious production usage, but instead as a tool for curious sysadmins to easily experiment 15 | with Matrix 2.0 in a simple docker compose environment. As of Nov 2024, it's considered beta. 16 | 17 | In particular, this has: 18 | * No support, security or maintenance guarantees whatsoever 19 | * No high availability, horizontal scalability, elastic scaling, clustering, backup etc. 20 | * No admin interface 21 | * No monitoring 22 | * No fancy config management (eg ansible), just env vars and templates 23 | * No fancy secret management (stored in plaintext on disk) 24 | * No UDP traffic or TURN for LiveKit (all traffic is tunnelled over TCP for simplicity) 25 | * No push server, integration manager, integrations, or identity lookup server 26 | 27 | For production-grade Matrix from Element, please see https://element.io/server-suite (ESS). 28 | 29 | ## To run 30 | 31 | 1. Install [Docker Compose](https://docs.docker.com/compose/install/). 32 | 2. If you're running on your local workstation, then [install mkcert](https://github.com/FiloSottile/mkcert#installation) to manage TLS. 33 | 34 | Then: 35 | 36 | ``` 37 | ./setup.sh 38 | 39 | # Point DNS for *.domain at your docker host, 40 | # Or if running on localhost with mkcert: 41 | # source .env; sudo sh -c "echo 127.0.0.1 $DOMAINS >> /etc/hosts" 42 | 43 | docker compose up 44 | # go to https://element on your domain. 45 | ``` 46 | 47 | ![docker demo](https://github.com/user-attachments/assets/c17e42f7-3442-478a-9ae4-ad2709885386) 48 | 49 | Watch the full video: 50 | 51 |
52 | 53 | 54 | 55 |
56 |
57 | 58 | For more info, see https://element.io/blog/experimenting-with-matrix-2-0-using-element-docker-demo/ 59 | 60 | ## To configure 61 | 62 | Check the .env file, or customise the templates in `/data-templates` and then `docker compose down && docker compose up -d`. 63 | 64 | In particular, you may wish to: 65 | * Point at your own SMTP server rather than mailhog 66 | * Use your own reverse proxy rather than the provided nginx 67 | * Use your own database cluster 68 | 69 | Container data gets stored in `./data`, and secrets in `./secrets`. 70 | N.B. that config files in `./data` will get overwritten by the templates from `./data-template` every time the cluster 71 | is launched. 72 | 73 | ## To admin 74 | 75 | ```bash 76 | # To upgrade 77 | docker compose pull 78 | ``` 79 | 80 | ```bash 81 | # To register a user 82 | docker compose exec mas mas-cli -c /data/config.yaml manage register-user 83 | ``` 84 | 85 | ## Diagnostics 86 | 87 | ```bash 88 | # check that OIDC is working - useful for debugging TLS problems 89 | docker compose exec mas mas-cli -c /data/config.yaml doctor 90 | ```` 91 | 92 | ## Other resources 93 | 94 | * This was originally based on https://github.com/element-hq/synapse/tree/master/contrib/docker_compose_workers 95 | * Other guides for MAS and Element Call from Sebastian Späth at: 96 | * https://sspaeth.de/2024/08/matrix-server-with-nextcloud-login/ 97 | * https://sspaeth.de/2024/11/sfu/ 98 | * https://cyberhost.uk/element-matrix-setup/ is a good Matrix 1.0 docker-compose guide too 99 | 100 | ## Todo 101 | 102 | * [ ] pop up https://element in your browser once synapse has started up successfully for the first time, perhaps 103 | * [ ] test $VOLUME_PATH (or remove it) 104 | * [ ] swap nginx for caddy or traefik to simplify Letsencrypt 105 | * [ ] set up livekit TURN (tcp & udp port 443) for better firewall traversal and voip performance 106 | -------------------------------------------------------------------------------- /init/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | #set -x 5 | 6 | # basic script to generate templated config for our various docker images. 7 | # it runs in its own alpine docker image to pull in yq as a dep, and to let the whole thing be managed by docker-compose. 8 | 9 | # by this point, synapse & mas should generated default config files & secrets 10 | # via generate-synapse-secrets.sh and generate-mas-secrets.sh 11 | 12 | if [[ ! -s /secrets/synapse/signing.key ]] # TODO: check for existence of other secrets? 13 | then 14 | # extract synapse secrets from the config and move them into ./secrets 15 | echo "Extracting generated synapse secrets..." 16 | mkdir -p /secrets/synapse 17 | for secret in registration_shared_secret macaroon_secret_key form_secret 18 | do 19 | yq .$secret /data/synapse/homeserver.yaml.default > /secrets/synapse/$secret 20 | done 21 | # ...and files too, just to keep all our secrets in one place 22 | mv /data/synapse/${DOMAIN}.signing.key /secrets/synapse/signing.key 23 | fi 24 | 25 | if [[ ! -f /secrets/mas/secrets ]] # TODO: check for existence of other secrets? 26 | then 27 | echo "Extracting generated MAS secrets..." 28 | mkdir -p /secrets/mas 29 | # extract MAS secrets from the config and move them into ./secrets 30 | for secret in matrix.secret 31 | do 32 | yq .$secret /data/mas/config.yaml.default > /secrets/mas/$secret 33 | done 34 | yq '(.secrets) as $s 35 | ireduce({}; setpath($s | path; $s))' /data/mas/config.yaml.default > /secrets/mas/secrets 36 | head -c16 /dev/urandom | base64 | tr -d '=' > /secrets/mas/client.secret 37 | fi 38 | 39 | if [[ ! -s /secrets/postgres/postgres_password ]] 40 | then 41 | mkdir -p /secrets/postgres 42 | head -c16 /dev/urandom | base64 | tr -d '=' > /secrets/postgres/postgres_password 43 | fi 44 | 45 | mkdir -p /secrets/livekit 46 | if [[ ! -s /secrets/livekit/livekit_api_key ]] 47 | then 48 | (echo -n API; (head -c8 /dev/urandom | base64)) | tr -d '=' > /secrets/livekit/livekit_api_key 49 | fi 50 | if [[ ! -s /secrets/livekit/livekit_secret_key ]] 51 | then 52 | head -c28 /dev/urandom | base64 | tr -d '=' > /secrets/livekit/livekit_secret_key 53 | fi 54 | 55 | # TODO: compare the default generated config with our templates to see if our templates are stale 56 | # we'd have to strip out the secrets from the generated configs to be able to diff them sensibly 57 | 58 | # now we have our secrets extracted from the default configs, overwrite the configs with our templates 59 | 60 | # for simplicity, we just use envsubst for now rather than ansible+jinja or something. 61 | template() { 62 | dir=$1 63 | echo "Templating configs in $dir" 64 | for file in `find $dir -type f` 65 | do 66 | mkdir -p `dirname ${file/-template/}` 67 | envsubst < $file > ${file/-template/} 68 | done 69 | } 70 | 71 | export CONFIG_HEADER="# WARNING: This file is autogenerated by element-quick-start from templates" 72 | export DOLLAR='$' # evil hack to escape dollars in config files 73 | ( 74 | export SECRETS_SYNAPSE_REGISTRATION_SHARED_SECRET=$(" 78 | app_name: Matrix 79 | enable_notifs: true 80 | notif_for_new_users: false 81 | client_base_url: https://${ELEMENT_WEB_FQDN} 82 | validation_token_lifetime: 15m 83 | invite_client_location: https://${ELEMENT_WEB_FQDN} 84 | subjects: 85 | message_from_person_in_room: "[%(app)s] You have a message on %(app)s from %(person)s in the %(room)s room..." 86 | message_from_person: "[%(app)s] You have a message on %(app)s from %(person)s..." 87 | messages_from_person: "[%(app)s] You have messages on %(app)s from %(person)s..." 88 | messages_in_room: "[%(app)s] You have messages on %(app)s in the %(room)s room..." 89 | messages_in_room_and_others: "[%(app)s] You have messages on %(app)s in the %(room)s room and others..." 90 | messages_from_person_and_others: "[%(app)s] You have messages on %(app)s from %(person)s and others..." 91 | invite_from_person_to_room: "[%(app)s] %(person)s has invited you to join the %(room)s room on %(app)s..." 92 | invite_from_person: "[%(app)s] %(person)s has invited you to chat on %(app)s..." 93 | password_reset: "[%(server_name)s] Password reset" 94 | email_validation: "[%(server_name)s] Validate your email" 95 | 96 | 97 | # temporarily boost rate-limits to avoid breaking WIP MatrixRTC signalling 98 | rc_message: 99 | per_second: 2 100 | burst_count: 15 101 | 102 | experimental_features: 103 | msc3861: # OIDC 104 | enabled: true 105 | issuer: https://${DOMAIN}/ 106 | client_id: ${MAS_CLIENT_ID} 107 | client_auth_method: client_secret_basic 108 | client_secret: '${SECRETS_MAS_CLIENT_SECRET}' 109 | admin_token: '${SECRETS_MAS_MATRIX_SECRET}' 110 | account_management_url: "https://${MAS_FQDN}/account" 111 | 112 | # QR login 113 | msc4108_enabled: true 114 | 115 | # MSC3266: Room summary API. Used for knocking over federation 116 | msc3266_enabled: true 117 | 118 | # state_after in /sync v2, needed for reliable state in busy rooms 119 | # especially Element Call 120 | msc4222_enabled: true 121 | 122 | # disable_badge_count to get accurate app badge counts in Element X 123 | msc4076_enabled: true 124 | 125 | # The maximum allowed duration by which sent events can be delayed, as 126 | # per MSC4140. Must be a positive value if set. Defaults to no 127 | # duration (null), which disallows sending delayed events. 128 | # Needed for MatrixRTC to avoid stuck calls 129 | max_event_delay_duration: 24h 130 | 131 | # vim:ft=yaml 132 | -------------------------------------------------------------------------------- /data-template/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | ${CONFIG_HEADER} 2 | 3 | # taken from https://element-hq.github.io/synapse/latest/reverse_proxy.html 4 | # mixed with https://github.com/wmnnd/nginx-certbot/tree/master/etc/nginx/conf.d/nginx 5 | 6 | # log_format vhosts '$host $remote_addr - $remote_user [$time_local] ' 7 | # '"$request" $status $body_bytes_sent ' 8 | # '"$http_referer" "$http_user_agent"'; 9 | # access_log /dev/stdout vhosts; 10 | 11 | server { 12 | server_name ${DOMAIN}; 13 | server_tokens off; 14 | 15 | listen 80; 16 | 17 | location /.well-known/acme-challenge/ { 18 | root /var/www/certbot; 19 | } 20 | 21 | location ~ ^/.well-known/(matrix|element)/ { 22 | root /var/www; 23 | } 24 | 25 | # XXX: is this right? or should auth.$DOMAIN be the issuer? 26 | location /.well-known/openid-configuration { 27 | proxy_pass http://mas:8080; 28 | proxy_http_version 1.1; 29 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 30 | } 31 | 32 | location / { 33 | return 301 https://${DOLLAR}host${DOLLAR}request_uri; 34 | } 35 | } 36 | 37 | server { 38 | server_name ${DOMAIN}; 39 | server_tokens off; 40 | 41 | include /etc/nginx/conf.d/include/ssl.conf; 42 | 43 | location = / { 44 | return 302 https://${ELEMENT_WEB_FQDN}; 45 | } 46 | 47 | location ~ ^/.well-known/(matrix|element)/ { 48 | root /var/www; 49 | } 50 | 51 | # XXX: is this right? or should auth.$DOMAIN be the issuer? 52 | location /.well-known/openid-configuration { 53 | proxy_pass http://mas:8080; 54 | proxy_http_version 1.1; 55 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 56 | } 57 | } 58 | 59 | server { 60 | server_name ${ELEMENT_WEB_FQDN}; 61 | server_tokens off; 62 | 63 | include /etc/nginx/conf.d/include/ssl.conf; 64 | 65 | location / { 66 | proxy_pass http://element-web; 67 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 68 | } 69 | } 70 | 71 | server { 72 | server_name ${ELEMENT_CALL_FQDN}; 73 | server_tokens off; 74 | 75 | include /etc/nginx/conf.d/include/ssl.conf; 76 | 77 | location / { 78 | proxy_pass http://element-call:8080; 79 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 80 | } 81 | } 82 | 83 | server { 84 | server_name ${MAS_FQDN}; 85 | server_tokens off; 86 | 87 | include /etc/nginx/conf.d/include/ssl.conf; 88 | 89 | location / { 90 | proxy_pass http://mas:8080; 91 | proxy_http_version 1.1; 92 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 93 | } 94 | } 95 | 96 | server { 97 | server_name ${LIVEKIT_FQDN}; 98 | server_tokens off; 99 | 100 | include /etc/nginx/conf.d/include/ssl.conf; 101 | 102 | location / { 103 | proxy_pass http://livekit:7880; 104 | proxy_http_version 1.1; 105 | proxy_set_header Upgrade ${DOLLAR}http_upgrade; 106 | proxy_set_header Connection "upgrade"; 107 | proxy_set_header Host ${DOLLAR}host; 108 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 109 | } 110 | } 111 | 112 | server { 113 | server_name ${LIVEKIT_JWT_FQDN}; 114 | server_tokens off; 115 | 116 | include /etc/nginx/conf.d/include/ssl.conf; 117 | 118 | location / { 119 | proxy_pass http://livekit-jwt:8080; 120 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 121 | } 122 | } 123 | 124 | server { 125 | server_name ${HOMESERVER_FQDN}; 126 | server_tokens off; 127 | 128 | include /etc/nginx/conf.d/include/ssl.conf; 129 | 130 | # For the federation port 131 | listen 8448 ssl default_server; 132 | listen [::]:8448 ssl default_server; 133 | 134 | # pass auth to MAS 135 | location ~ ^/_matrix/client/(.*)/(login|logout|refresh) { 136 | proxy_pass http://mas:8080; 137 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 138 | } 139 | 140 | # use the generic worker as a synchrotron: 141 | # taken from https://element-hq.github.io/synapse/latest/workers.html#synapseappgeneric_worker 142 | 143 | location ~ ^/_matrix/client/(r0|v3)/sync${DOLLAR} { 144 | proxy_pass http://synapse-generic-worker-1:8081; 145 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 146 | proxy_set_header X-Forwarded-Proto ${DOLLAR}scheme; 147 | } 148 | 149 | location ~ ^/_matrix/client/(api/v1|r0|v3)/events${DOLLAR} { 150 | proxy_pass http://synapse-generic-worker-1:8081; 151 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 152 | proxy_set_header X-Forwarded-Proto ${DOLLAR}scheme; 153 | } 154 | 155 | location ~ ^/_matrix/client/(api/v1|r0|v3)/initialSync${DOLLAR} { 156 | proxy_pass http://synapse-generic-worker-1:8081; 157 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 158 | proxy_set_header X-Forwarded-Proto ${DOLLAR}scheme; 159 | } 160 | 161 | location ~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync${DOLLAR} { 162 | proxy_pass http://synapse-generic-worker-1:8081; 163 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 164 | proxy_set_header X-Forwarded-Proto ${DOLLAR}scheme; 165 | } 166 | 167 | location / { 168 | proxy_pass http://synapse:8008; 169 | proxy_set_header X-Forwarded-For ${DOLLAR}remote_addr; 170 | proxy_set_header X-Forwarded-Proto ${DOLLAR}scheme; 171 | proxy_set_header Host ${DOLLAR}host; 172 | 173 | # Nginx by default only allows file uploads up to 1M in size 174 | # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml 175 | client_max_body_size 50M; 176 | } 177 | 178 | # Synapse responses may be chunked, which is an HTTP/1.1 feature. 179 | proxy_http_version 1.1; 180 | } 181 | 182 | -------------------------------------------------------------------------------- /compose.yml: -------------------------------------------------------------------------------- 1 | # FIXME: define a frontend & backend network, and only expose backend services to the frontend (nginx) 2 | 3 | networks: 4 | backend: 5 | 6 | secrets: 7 | postgres_password: 8 | file: secrets/postgres/postgres_password 9 | synapse_signing_key: 10 | file: secrets/synapse/signing.key 11 | livekit_api_key: 12 | file: secrets/livekit/livekit_api_key 13 | livekit_secret_key: 14 | file: secrets/livekit/livekit_secret_key 15 | 16 | services: 17 | # XXX: consider factor out secret generation from the compose.yml 18 | 19 | # dependencies for optionally generating default configs + secrets 20 | generate-synapse-secrets: 21 | image: ghcr.io/element-hq/synapse:latest 22 | user: $USER_ID:$GROUP_ID 23 | restart: "no" 24 | volumes: 25 | - ${VOLUME_PATH}/data/synapse:/data:rw 26 | - ${VOLUME_PATH}/init/generate-synapse-secrets.sh:/entrypoint.sh 27 | env_file: .env 28 | environment: 29 | SYNAPSE_CONFIG_DIR: /data 30 | SYNAPSE_CONFIG_PATH: /data/homeserver.yaml.default 31 | SYNAPSE_SERVER_NAME: ${DOMAIN} 32 | SYNAPSE_REPORT_STATS: ${REPORT_STATS} 33 | entrypoint: "/entrypoint.sh" 34 | 35 | generate-mas-secrets: 36 | restart: "no" 37 | image: ghcr.io/element-hq/matrix-authentication-service:latest 38 | user: $USER_ID:$GROUP_ID 39 | volumes: 40 | - ${VOLUME_PATH}/data/mas:/data:rw 41 | # FIXME: stop this regenerating a spurious default config every time 42 | # We can't do the same approach as synapse (unless use a debug image of MAS) as MAS is distroless and has no bash. 43 | command: "config generate -o /data/config.yaml.default" 44 | 45 | # dependency for templating /data-template into /data (having extracted any secrets from any default generated configs) 46 | init: 47 | build: init 48 | user: $USER_ID:$GROUP_ID 49 | restart: "no" 50 | volumes: 51 | - ${VOLUME_PATH}/secrets:/secrets 52 | - ${VOLUME_PATH}/data:/data 53 | - ${VOLUME_PATH}/data-template:/data-template 54 | - ${VOLUME_PATH}/init/init.sh:/init.sh 55 | command: "/init.sh" 56 | env_file: .env 57 | depends_on: 58 | generate-synapse-secrets: 59 | condition: service_completed_successfully 60 | generate-mas-secrets: 61 | condition: service_completed_successfully 62 | 63 | nginx: 64 | image: nginx:latest 65 | restart: unless-stopped 66 | ports: 67 | - "80:80" 68 | - "443:443" 69 | - "8448:8448" 70 | # shutdown fast so we can iterate rapidly on compose.yml 71 | stop_grace_period: 0s 72 | volumes: 73 | - ${VOLUME_PATH}/data/nginx/conf.d:/etc/nginx/conf.d 74 | - ${VOLUME_PATH}/data/nginx/www:/var/www 75 | - ${VOLUME_PATH}/data/ssl:/etc/nginx/ssl 76 | command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" 77 | networks: 78 | backend: 79 | aliases: # so our containers can resolve the LB 80 | - $DOMAIN 81 | - $HOMESERVER_FQDN 82 | - $ELEMENT_WEB_FQDN 83 | - $ELEMENT_CALL_FQDN 84 | - $MAS_FQDN 85 | depends_on: 86 | init: 87 | condition: service_completed_successfully 88 | 89 | certbot: 90 | image: certbot/certbot:latest 91 | restart: unless-stopped 92 | volumes: 93 | - ${VOLUME_PATH}/data/certbot/conf:/etc/letsencrypt 94 | - ${VOLUME_PATH}/data/certbot/www:/var/www/certbot 95 | - ${VOLUME_PATH}/data/ssl:/data/ssl 96 | entrypoint: "/bin/sh -c 'trap exit TERM; \ 97 | while [ -e /etc/letsencrypt/live ]; \ 98 | do sleep 30; certbot --webroot -w /var/www/certbot renew; \ 99 | cp /etc/letsencrypt/live/$DOMAIN/*.pem /data/ssl; \ 100 | sleep 12h & wait $${!}; \ 101 | done;'" 102 | 103 | postgres: 104 | image: postgres:latest 105 | restart: unless-stopped 106 | volumes: 107 | - ${VOLUME_PATH}/data/postgres:/var/lib/postgresql/data:rw 108 | - ${VOLUME_PATH}/scripts/create-multiple-postgresql-databases.sh:/docker-entrypoint-initdb.d/create-multiple-postgresql-databases.sh 109 | networks: 110 | - backend 111 | environment: 112 | POSTGRES_MULTIPLE_DATABASES: synapse,mas 113 | POSTGRES_USER: matrix # FIXME: use different username+passwords for synapse & MAS DBs. 114 | POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password 115 | POSTGRES_INITDB_ARGS: --encoding=UTF8 --locale=C 116 | PGDATA: /var/lib/postgresql/data/data # otherwise it clashes with .gitkeep in the parent dir 117 | secrets: 118 | - postgres_password 119 | healthcheck: 120 | test: ["CMD-SHELL", "pg_isready -U matrix"] 121 | start_period: "1s" 122 | interval: "1s" 123 | timeout: "5s" 124 | depends_on: 125 | init: 126 | condition: service_completed_successfully 127 | 128 | redis: 129 | image: redis:latest 130 | restart: unless-stopped 131 | # healthcheck: 132 | # test: ["CMD-SHELL", "redis-cli ping | grep PONG"] 133 | # interval: 1s 134 | # timeout: 3s 135 | # retries: 5 136 | networks: 137 | - backend 138 | 139 | synapse: 140 | image: ghcr.io/element-hq/synapse:latest 141 | user: $USER_ID:$GROUP_ID 142 | restart: unless-stopped 143 | volumes: 144 | - ${VOLUME_PATH}/data/synapse:/data:rw 145 | - ${VOLUME_PATH}/data/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt 146 | # ports: 147 | # - 8008:8008 148 | networks: 149 | - backend 150 | environment: 151 | SYNAPSE_CONFIG_DIR: /data 152 | SYNAPSE_CONFIG_PATH: /data/homeserver.yaml 153 | secrets: 154 | - synapse_signing_key 155 | depends_on: 156 | redis: 157 | condition: service_started 158 | postgres: 159 | condition: service_healthy 160 | init: 161 | condition: service_completed_successfully 162 | 163 | synapse-generic-worker-1: 164 | image: ghcr.io/element-hq/synapse:latest 165 | user: $USER_ID:$GROUP_ID 166 | restart: unless-stopped 167 | entrypoint: ["/start.py", "run", "--config-path=/data/homeserver.yaml", "--config-path=/data/workers/synapse-generic-worker-1.yaml"] 168 | healthcheck: 169 | test: ["CMD-SHELL", "curl -fSs http://localhost:8081/health || exit 1"] 170 | start_period: "5s" 171 | interval: "15s" 172 | timeout: "5s" 173 | networks: 174 | - backend 175 | volumes: 176 | - ${VOLUME_PATH}/data/synapse:/data:rw 177 | - ${VOLUME_PATH}/data/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt 178 | environment: 179 | SYNAPSE_WORKER: synapse.app.generic_worker 180 | # Expose port if required so your reverse proxy can send requests to this worker 181 | # Port configuration will depend on how the http listener is defined in the worker configuration file 182 | # ports: 183 | # - 8081:8081 184 | secrets: 185 | - synapse_signing_key 186 | depends_on: 187 | - synapse 188 | 189 | synapse-federation-sender-1: 190 | image: ghcr.io/element-hq/synapse:latest 191 | user: $USER_ID:$GROUP_ID 192 | restart: unless-stopped 193 | entrypoint: ["/start.py", "run", "--config-path=/data/homeserver.yaml", "--config-path=/data/workers/synapse-federation-sender-1.yaml"] 194 | healthcheck: 195 | disable: true 196 | networks: 197 | - backend 198 | volumes: 199 | - ${VOLUME_PATH}/data/synapse:/data:rw # Replace VOLUME_PATH with the path to your Synapse volume 200 | - ${VOLUME_PATH}/data/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt 201 | environment: 202 | SYNAPSE_WORKER: synapse.app.federation_sender 203 | # ports: 204 | # - 8082:8082 205 | secrets: 206 | - synapse_signing_key 207 | depends_on: 208 | - synapse 209 | 210 | mas: 211 | image: ghcr.io/element-hq/matrix-authentication-service:latest 212 | restart: unless-stopped 213 | # ports: 214 | # - 8083:8080 215 | volumes: 216 | - ${VOLUME_PATH}/data/mas:/data:rw 217 | - ${VOLUME_PATH}/data/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt 218 | networks: 219 | - backend 220 | # FIXME: do we also need to sync the db? 221 | command: "server --config=/data/config.yaml" 222 | depends_on: 223 | postgres: 224 | condition: service_healthy 225 | init: 226 | condition: service_completed_successfully 227 | 228 | # as a basic local MTA 229 | mailhog: 230 | image: mailhog/mailhog:latest 231 | restart: unless-stopped 232 | # ports: 233 | # - 8025:8025 234 | # - 1025:1025 235 | networks: 236 | - backend 237 | 238 | element-web: 239 | image: vectorim/element-web:latest 240 | restart: unless-stopped 241 | # ports: 242 | # - 8080:80 243 | healthcheck: 244 | test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:80/version || exit 1"] 245 | start_period: "5s" 246 | interval: "15s" 247 | timeout: "5s" 248 | networks: 249 | - backend 250 | volumes: 251 | - ${VOLUME_PATH}/data/element-web/config.json:/app/config.json 252 | depends_on: 253 | init: 254 | condition: service_completed_successfully 255 | 256 | element-call: 257 | image: ghcr.io/element-hq/element-call:latest-ci 258 | restart: unless-stopped 259 | # ports: 260 | # - 8082:80 261 | networks: 262 | - backend 263 | volumes: 264 | - ${VOLUME_PATH}/data/element-call/config.json:/app/config.json 265 | depends_on: 266 | init: 267 | condition: service_completed_successfully 268 | 269 | livekit: 270 | image: livekit/livekit-server:latest 271 | restart: unless-stopped 272 | volumes: 273 | - ${VOLUME_PATH}/data/livekit/config.yaml:/etc/livekit.yaml 274 | command: --config /etc/livekit.yaml --node-ip ${LIVEKIT_NODE_IP} 275 | ports: 276 | # - 7880:7880 # HTTP listener 277 | - 7881:7881 # TCP WebRTC transport, advertised via SDP 278 | 279 | # TODO: expose livekit-turn on TCP & UDP 443 via nginx 280 | # At least this would allow UDP turn on port 443 for better perf. 281 | 282 | # You can't expose a massive range here as it literally sets up 10,000 userland listeners, which takes forever 283 | # and will clash with any existing high-numbered ports. 284 | # So for now, tunnel everything via TCP 7881. FIXME! 285 | #- 50000-60000:50000-60000/tcp # TCP media 286 | #- 50000-60000:50000-60000/udp # UDP media 287 | networks: 288 | - backend 289 | depends_on: 290 | init: 291 | condition: service_completed_successfully 292 | redis: 293 | condition: service_started 294 | 295 | livekit-jwt: 296 | build: 297 | # evil hack to pull in bash so we can run an entrypoint.sh 298 | # FIXME: it's a bit wasteful; the alternative would be to modify lk-jwt-service to pick up secrets from disk 299 | # Another alternative would be to factor out secret generation from compose.yml and create an .env up front 300 | dockerfile_inline: | 301 | FROM ghcr.io/element-hq/lk-jwt-service:latest-ci AS builder 302 | FROM alpine:latest 303 | RUN apk update && apk add bash 304 | COPY --from=builder /lk-jwt-service / 305 | restart: unless-stopped 306 | volumes: 307 | - ${VOLUME_PATH}/data/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt 308 | - ${VOLUME_PATH}/scripts/livekit-jwt-entrypoint.sh:/entrypoint.sh 309 | entrypoint: /entrypoint.sh 310 | env_file: .env 311 | deploy: 312 | restart_policy: 313 | condition: on-failure 314 | networks: 315 | - backend 316 | secrets: 317 | - livekit_api_key 318 | - livekit_secret_key 319 | depends_on: 320 | init: 321 | condition: service_completed_successfully 322 | livekit: 323 | condition: service_started 324 | -------------------------------------------------------------------------------- /data-template/livekit/config.yaml: -------------------------------------------------------------------------------- 1 | ${CONFIG_HEADER} 2 | # From https://github.com/livekit/livekit/blob/master/config-sample.yaml 3 | 4 | # Copyright 2024 LiveKit, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | # main TCP port for RoomService and RTC endpoint 19 | # for production setups, this port should be placed behind a load balancer with TLS 20 | port: 7880 21 | 22 | # when redis is set, LiveKit will automatically operate in a fully distributed fashion 23 | # clients could connect to any node and be routed to the same room 24 | redis: 25 | address: redis:6379 26 | # db: 0 27 | # username: myuser 28 | # password: mypassword 29 | # To use sentinel remove the address key above and add the following 30 | # sentinel_master_name: livekit 31 | # sentinel_addresses: 32 | # - livekit-redis-node-0.livekit-redis-headless:26379 33 | # - livekit-redis-node-1.livekit-redis-headless:26379 34 | # If you use a different set of credentials for sentinel add 35 | # sentinel_username: user 36 | # sentinel_password: pass 37 | # 38 | # To use TLS with redis 39 | # tls: 40 | # enabled: true 41 | # # when set to true, LiveKit will not verify the server's certificate, defaults to true 42 | # insecure: false 43 | # server_name: myserver.com 44 | # # file containing trusted root certificates for verification 45 | # ca_cert_file: /path/to/ca.crt 46 | # client_cert_file: /path/to/client.crt 47 | # client_key_file: /path/to/client.key 48 | # 49 | # To use cluster remove the address key above and add the following 50 | # cluster_addresses: 51 | # - livekit-redis-node-0.livekit-redis-headless:6379 52 | # - livekit-redis-node-1.livekit-redis-headless:6380 53 | # And it will use the password key above as cluster password 54 | # And the db key will not be used due to cluster mode not support it. 55 | 56 | # WebRTC configuration 57 | rtc: 58 | # UDP ports to use for client traffic. 59 | # this port range should be open for inbound traffic on the firewall 60 | port_range_start: 50000 61 | port_range_end: 60000 62 | # when set, LiveKit enable WebRTC ICE over TCP when UDP isn't available 63 | # this port *cannot* be behind load balancer or TLS, and must be exposed on the node 64 | # WebRTC transports are encrypted and do not require additional encryption 65 | # only 80/443 on public IP are allowed if less than 1024 66 | tcp_port: 7881 67 | # when set to true, attempts to discover the host's public IP via STUN 68 | # this is useful for cloud environments such as AWS & Google where hosts have an internal IP 69 | # that maps to an external one 70 | use_external_ip: false 71 | # # when set, LiveKit will attempt to use a UDP mux so all UDP traffic goes through 72 | # # listed port(s). To maximize system performance, we recommend using a range of ports 73 | # # greater or equal to the number of vCPUs on the machine. 74 | # # port_range_start & end must not be set for this config to take effect 75 | # udp_port: 7882-7892 76 | # # when set to true, server will use a lite ice agent, that will speed up ice connection, but 77 | # # might cause connect issue if server running behind NAT. 78 | # use_ice_lite: true 79 | # # optional STUN servers for LiveKit clients to use. Clients will be configured to use these STUN servers automatically. 80 | # # by default LiveKit clients use Google's public STUN servers 81 | # stun_servers: 82 | # - server1 83 | # # optional TURN servers for clients. This isn't necessary if using embedded TURN server (see below). 84 | # turn_servers: 85 | # - host: myhost.com 86 | # port: 443 87 | # # tls, tcp, or udp 88 | # protocol: tls 89 | # username: "" 90 | # credential: "" 91 | # # allows LiveKit to monitor congestion when sending streams and automatically 92 | # # manage bandwidth utilization to avoid congestion/loss. Enabled by default 93 | # congestion_control: 94 | # enabled: true 95 | # # in the unlikely event of highly congested networks, SFU may choose to pause some tracks 96 | # # in order to allow others to stream smoothly. You can disable this behavior here 97 | # allow_pause: true 98 | # # allows automatic connection fallback to TCP and TURN/TLS (if configured) when UDP has been unstable, default true 99 | # allow_tcp_fallback: true 100 | # # number of packets to buffer in the SFU for video, defaults to 500 101 | # packet_buffer_size_video: 500 102 | # # number of packets to buffer in the SFU for audio, defaults to 200 103 | # packet_buffer_size_audio: 200 104 | # # minimum amount of time between pli/fir rtcp packets being sent to an individual 105 | # # producer. Increasing these times can lead to longer black screens when new participants join, 106 | # # while reducing them can lead to higher stream bitrate. 107 | # pli_throttle: 108 | # low_quality: 500ms 109 | # mid_quality: 1s 110 | # high_quality: 1s 111 | # # when set, Livekit will collect loopback candidates, it is useful for some VM have public address mapped to its loopback interface. 112 | # enable_loopback_candidate: true 113 | # # network interface filter. If the machine has more than one network interface and you'd like it to use or skip specific interfaces 114 | # # both inclusion and exclusion filters can be used together. If neither is defined (default), all interfaces on the machine will be used. 115 | # # If both of them are set, then only include takes effect. 116 | # interfaces: 117 | # includes: 118 | # - en0 119 | # excludes: 120 | # - docker0 121 | # # ip address filter. If the machine has more than one ip address and you'd like it to use or skip specific ips, 122 | # # both inclusion and exclusion CIDR filters can be used together. If neither is defined (default), all ip on the machine will be used. 123 | # # If both of them are set, then only include takes effect. 124 | # ips: 125 | # includes: 126 | # - 10.0.0.0/16 127 | # excludes: 128 | # - 192.168.1.0/24 129 | # # Set to true to enable mDNS name candidate. This should be left disabled for most users. 130 | # # when enabled, it will impact performance since each PeerConnection will process the same mDNS message independently 131 | # use_mdns: true 132 | # # Set to false to disable strict ACKs for peer connections where LiveKit is the dialing side, 133 | # # ie. subscriber peer connections. Disabling strict ACKs will prevent clients that do not ACK 134 | # # peer connections from getting kicked out of rooms by the monitor. Note that if strict ACKs 135 | # # are disabled and clients don't ACK opened peer connections, only reliable, ordered delivery 136 | # # will be available. 137 | # strict_acks: true 138 | # # enable batch write to merge network write system calls to reduce cpu usage. Outgoing packets 139 | # # will be queued until length of queue equal to `batch_size` or time elapsed since last write exceeds `max_flush_interval`. 140 | # batch_io: 141 | # batch_size: 128 142 | # max_flush_interval: 2ms 143 | # # max number of bytes to buffer for data channel. 0 means unlimited. 144 | # # when this limit is breached, data messages will be dropped till the buffered amount drops below this limit. 145 | # data_channel_max_buffered_amount: 0 146 | 147 | # when enabled, LiveKit will expose prometheus metrics on :6789/metrics 148 | # prometheus_port: 6789 149 | 150 | # API key / secret pairs. 151 | # Keys are used for JWT authentication, server APIs would require a keypair in order to generate access tokens 152 | # and make calls to the server 153 | keys: 154 | ${SECRETS_LIVEKIT_API_KEY}: '${SECRETS_LIVEKIT_SECRET_KEY}' 155 | # Logging config 156 | # logging: 157 | # # log level, valid values: debug, info, warn, error 158 | # level: info 159 | # # log level for pion, default error 160 | # pion_level: error 161 | # # when set to true, emit json fields 162 | # json: false 163 | # # for production setups, enables sampling algorithm 164 | # # https://github.com/uber-go/zap/blob/master/FAQ.md#why-sample-application-logs 165 | # sample: false 166 | 167 | # Default room config 168 | # Each room created will inherit these settings. If rooms are created explicitly with CreateRoom, they will take 169 | # precedence over defaults 170 | # room: 171 | # # allow rooms to be automatically created when participants join, defaults to true 172 | # # auto_create: false 173 | # # number of seconds to keep the room open if no one joins 174 | # empty_timeout: 300 175 | # # number of seconds to keep the room open after everyone leaves 176 | # departure_timeout: 20 177 | # # limit number of participants that can be in a room, 0 for no limit 178 | # max_participants: 0 179 | # # only accept specific codecs for clients publishing to this room 180 | # # this is useful to standardize codecs across clients 181 | # # other supported codecs are video/h264, video/vp9, video/av1, audio/red 182 | # enabled_codecs: 183 | # - mime: audio/opus 184 | # - mime: video/vp8 185 | # # allow tracks to be unmuted remotely, defaults to false 186 | # # tracks can always be muted from the Room Service APIs 187 | # enable_remote_unmute: true 188 | # # control playout delay in ms of video track (and associated audio track) 189 | # playout_delay: 190 | # enabled: true 191 | # min: 100 192 | # max: 2000 193 | # # improves A/V sync when playout_delay set to a value larger than 200ms. It will disables transceiver re-use 194 | # # so not recommended for rooms with frequent subscription changes 195 | # sync_streams: true 196 | 197 | # Webhooks 198 | # when configured, LiveKit notifies your URL handler with room events 199 | # webhook: 200 | # # the API key to use in order to sign the message 201 | # # this must match one of the keys LiveKit is configured with 202 | # api_key: 203 | # # list of URLs to be notified of room events 204 | # urls: 205 | # - https://your-host.com/handler 206 | 207 | # Signal Relay 208 | # since v1.4.0, a more reliable, psrpc based signal relay is available 209 | # this gives us the ability to reliably proxy messages between a signal server and RTC node 210 | # signal_relay: 211 | # # amount of time a message delivery is tried before giving up 212 | # retry_timeout: 30s 213 | # # minimum amount of time to wait for RTC node to ack, 214 | # # retries use exponentially increasing wait on every subsequent try 215 | # # with an upper bound of max_retry_interval 216 | # min_retry_interval: 500ms 217 | # # maximum amount of time to wait for RTC node to ack 218 | # max_retry_interval: 5s 219 | # # number of messages to buffer before dropping 220 | # stream_buffer_size: 1000 221 | 222 | # PSRPC 223 | # since v1.5.1, a more reliable, psrpc based internal rpc 224 | # psrpc: 225 | # # maximum number of rpc attempts 226 | # max_attempts: 3 227 | # # initial time to wait for calls to complete 228 | # timeout: 500ms 229 | # # amount of time added to the timeout after each failure 230 | # backoff: 500ms 231 | # # number of messages to buffer before dropping 232 | # buffer_size: 1000 233 | 234 | # customize audio level sensitivity 235 | # audio: 236 | # # minimum level to be considered active, 0-127, where 0 is loudest 237 | # # defaults to 30 238 | # active_level: 30 239 | # # percentile to measure, a participant is considered active if it has exceeded the 240 | # # ActiveLevel more than MinPercentile% of the time 241 | # # defaults to 40 242 | # min_percentile: 40 243 | # # frequency in ms to notify changes to clients, defaults to 500 244 | # update_interval: 500 245 | # # to prevent speaker updates from too jumpy, smooth out values over N samples 246 | # smooth_intervals: 4 247 | # # enable red encoding downtrack for opus only audio up track 248 | # active_red_encoding: true 249 | 250 | # turn server 251 | # turn: 252 | # # Uses TLS. Requires cert and key pem files by either: 253 | # # - using turn.secretName if deploying with our helm chart, or 254 | # # - setting LIVEKIT_TURN_CERT and LIVEKIT_TURN_KEY env vars with file locations, or 255 | # # - using cert_file and key_file below 256 | # # defaults to false 257 | # enabled: false 258 | # # defaults to 3478 - recommended to 443 if not running HTTP3/QUIC server 259 | # # only 53/80/443 are allowed if less than 1024 260 | # udp_port: 3478 261 | # # defaults to 5349 - if not using a load balancer, this must be set to 443 262 | # tls_port: 5349 263 | # # set UDP port range for TURN relay to connect to LiveKit SFU, by default it uses a any available port 264 | # relay_range_start: 1024 265 | # relay_range_end: 30000 266 | # # set external_tls to true if using a L4 load balancer to terminate TLS. when enabled, 267 | # # LiveKit expects unencrypted traffic on tls_port, and still advertise tls_port as a TURN/TLS candidate. 268 | # external_tls: true 269 | # # needs to match tls cert domain 270 | # domain: turn.myhost.com 271 | # # optional (set only if not using external TLS termination) 272 | # # cert_file: /path/to/cert.pem 273 | # # key_file: /path/to/key.pem 274 | 275 | # ingress server 276 | # ingress: 277 | # # Prefix used to generate RTMP URLs for RTMP ingress. 278 | # rtmp_base_url: "rtmp://my.domain.com/live" 279 | # # Prefix used to generate WHIP URLs for WHIP ingress. 280 | # whip_base_url: "http://my.domain.com/whip" 281 | 282 | # Region of the current node. Required if using regionaware node selector 283 | # region: us-west-2 284 | 285 | # # node selector 286 | # node_selector: 287 | # # default: any. valid values: any, sysload, cpuload, regionaware 288 | # kind: sysload 289 | # # priority used for selection of node when multiple are available 290 | # # default: random. valid values: random, sysload, cpuload, rooms, clients, tracks, bytespersec 291 | # sort_by: sysload 292 | # # used in sysload and regionaware 293 | # # do not assign room to node if load per CPU exceeds sysload_limit 294 | # sysload_limit: 0.7 295 | # # used in regionaware 296 | # # list of regions and their lat/lon coordinates 297 | # regions: 298 | # - name: us-west-2 299 | # lat: 44.19434095976287 300 | # lon: -123.0674908379146 301 | 302 | # # node limits 303 | # # set to -1 to disable a limit 304 | # limit: 305 | # # defaults to 400 tracks in & out per CPU, up to 8000 306 | # num_tracks: -1 307 | # # defaults to 1 GB/s, or just under 10 Gbps 308 | # bytes_per_sec: 1_000_000_000 309 | # # how many tracks (audio / video) that a single participant can subscribe at same time. 310 | # # if the limit is exceeded, subscriptions will be pending until any subscribed track has been unsubscribed. 311 | # # value less or equal than 0 means no limit. 312 | # subscription_limit_video: 0 313 | # subscription_limit_audio: 0 314 | # # limit size of room and participant's metadata, 0 for no limit 315 | # max_metadata_size: 0 316 | # # limit size of participant attributes, 0 for no limit 317 | # max_attributes_size: 0 318 | # # limit length of room names 319 | # max_room_name_length: 0 320 | # # limit length of participant identity 321 | # max_participant_identity_length: 0 322 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------