The easiest way to deploy OTT on your own server is to use docker-compose.
This method will run OTT in production mode, using redis and postgresql. However, this doesn't include a reverse proxy, so you will need to set that up yourself. Additionally, this will not automatically update OTT when a new version is released.
- Install docker and docker-compose
- Clone the repository
git clone https://github.com/dyc3/opentogethertube.git
cd opentogethertube
- Copy the example configuration file
cp env/example.toml env/production.toml
- Edit the configuration file to your liking.
- You'll likely want to grab a youtube api key from Google Cloud
- Run docker-compose
docker-compose up -d
Using docker-compose is the easiest way to deploy OTT, but you can also deploy it manually.
In order to run OTT, you will need the following components:
- A nodejs installation matches the versions specified in the package.json file.
- Redis
- PostgreSQL (recommended) or you can use sqlite (not recommended)
- A Youtube API key (obtained from Google Cloud)
Copy the example configuration file and edit it to your liking.
cp env/example.toml env/production.toml
After you have set those up, you need to run the database migrations, and build the client. You have to do this every time you update OTT.
corepack enable
yarn set version stable
yarn install
NODE_ENV=production yarn workspace ott-server run sequelize-cli db:migrate
yarn run build
After that, you can start the server.
NODE_ENV=production yarn start
Configuration is done through toml files in the env
directory. The easiest way to get started is to copy the example file and fill it out.
cp env/example.toml env/production.toml
Read more about configuration in the config docs.
SQLite is not recommended for production use, but it is possible. To use SQLite, you must set db.mode
to sqlite
in your configuration file. You must also use this command to run the database migrations.
NODE_ENV=production DB_MODE=sqlite yarn workspace ott-server run sequelize-cli db:migrate
While technically not required, it is highly recommended that you use a reverse proxy to serve OTT. This will allow you to use HTTPS, and to be able to serve applications on other domains on the same port. Running OTT without HTTPS is not supported.
A couple of notes on what needs to be proxied:
- Websocket upgrades
- All requests for
index.html
- It should be safe to use the proxy to serve all other static files, but it is not required.
- The
Set-Cookie
header in responses - The
Authorization
header in requests
Depending on how many layers of reverse proxies you are dealing with (eg. cloudflare -> nginx -> ott), you many need to set the trust_proxy
option in your OTT config to the number of proxies.
For nginx, the following configuration should work. Replace example.com
with your domain name.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
server_name example.com;
# SSL configuration -- likely generated by certbot
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_cache_bypass $http_upgrade;
proxy_pass_header Set-Cookie;
# optional, but recommended if you have problem with clients disconnecting and reconnecting frequently
proxy_connect_timeout 7d;
proxy_read_timeout 7d;
proxy_send_timeout 7d;
proxy_socket_keepalive on;
}
}