diff --git a/README.md b/README.md index 530509e..7ea7d57 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,6 @@ npm install 3. Optional, but recommended for production: Put the application (:8105) and the tracker (:8106) behind a reverse proxy (e.g. Caddy or nginx) and configure SSL. -## Configuration - -You can configure the application using environment variables: - -- `TRACKER_URL`: The WebTorrent tracker URL (default: `ws://localhost:8106`) -- `STUN_SERVER_URL`: The STUN server URL (optional - not used if unset) -- `TURN_SERVER_URL`: The TURN server URL (optional - not used if unset) -- `TURN_SECRET`: The static-auth-secret for the TURN server (required if `TURN_SERVER_URL` is set) - ## Running the Application 1. Start the tracker: @@ -56,17 +47,27 @@ You can configure the application using environment variables: npm run tracker ``` -2. Set the environment variables and start the server: +2. Create a `.env` file in the root directory of the project and set the environment variables: ```bash -export TRACKER_URL="wss://tracker.your-domain.com" # URL of the WebTorrent tracker - default: ws://localhost:8106, use wss:// for secure connections -export STUN_SERVER_URL="stun:stun.nextcloud.com:443" # Optional - there are public STUN servers available - not used if unset -export TURN_SERVER_URL="turn:your-turn-server-url" # Optional - you would need to set up your own TURN server - don't set this if you don't have one -export TURN_SECRET="your-static-auth-secret" # Required if you have a TURN server - don't set this if you don't have one +TRACKER_URL="wss://tracker.your-domain.com" # URL of the WebTorrent tracker - default: ws://localhost:8106, use wss:// for secure connections +STUN_SERVER_URL="stun:stun.nextcloud.com:443" # Optional - there are public STUN servers available - not used if unset +TURN_SERVER_URL="turn:your-turn-server-url" # Optional - you would need to set up your own TURN server - don't set this if you don't have one +TURN_SECRET="your-static-auth-secret" # Required if you have a TURN server - don't set this if you don't have one +``` + +If you are using a reverse proxy, you should set the `TRACKER_URL` to the URL of the tracker behind the reverse proxy, e.g. `wss://tracker.your-domain.com`. + +The STUN and TURN server URLs should be set to the public URLs of your STUN and TURN servers, if you have them. + +3. Start the application: + +```bash +. .env npm start ``` -3. Open your browser and navigate to `http://localhost:8105` (or the URL you have configured in your reverse proxy) +4. Open your browser and navigate to `http://localhost:8105` (or the URL you have configured in your reverse proxy) ## Usage @@ -85,4 +86,3 @@ npm start ## License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. - diff --git a/contrib/caddy/Caddyfile b/contrib/caddy/Caddyfile new file mode 100644 index 0000000..22feca9 --- /dev/null +++ b/contrib/caddy/Caddyfile @@ -0,0 +1,9 @@ +# Simple example of how to use Caddy for Transfer.coffee + +transfer.example www.transfer.example { + reverse_proxy localhost:8105 +} + +tracker.transfer.example { + reverse_proxy localhost:8106 +} diff --git a/contrib/systemd/transfercoffee-tracker.service b/contrib/systemd/transfercoffee-tracker.service new file mode 100644 index 0000000..41cc91d --- /dev/null +++ b/contrib/systemd/transfercoffee-tracker.service @@ -0,0 +1,23 @@ +[Unit] +Description=Transfer.coffee Tracker +After=syslog.target +After=network.target + +[Service] +RestartSec=2s +Type=simple + +User=transfercoffee +Group=transfercoffee + +# Replace /opt/transfer.coffee with where you cloned the repo to +WorkingDirectory=/opt/transfer.coffee +ExecStart=/usr/bin/npm run tracker + +Restart=always +RestartSec=86400s + +LimitNOFILE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/contrib/systemd/transfercoffee.service b/contrib/systemd/transfercoffee.service new file mode 100644 index 0000000..8487c0b --- /dev/null +++ b/contrib/systemd/transfercoffee.service @@ -0,0 +1,27 @@ +[Unit] +Description=Transfer.coffee +After=syslog.target +After=network.target + +[Service] +RestartSec=2s +Type=simple + +# Replace this with the user you want to run as +User=transfercoffee +Group=transfercoffee + +# Replace /opt/transfer.coffee with where you cloned the repo to +WorkingDirectory=/opt/transfer.coffee +ExecStart=/usr/bin/npm run start + +# Create a .env file in the root of the project with the environment variables (see README.md) +EnvironmentFile = /opt/transfer.coffee/.env + +Restart=always +RestartSec=86400s + +LimitNOFILE=infinity + +[Install] +WantedBy=multi-user.target