|
| 1 | +--- |
| 2 | +id: file-sharing |
| 3 | +title: File sharing |
| 4 | +--- |
| 5 | + |
| 6 | +## Deploying and configuring a demo file sharing service for Jitsi Meet |
| 7 | + |
| 8 | +The Jitsi Meet UI can use a file sharing service which implements the following [API](https://github.com/jitsi/jitsi-meet/blob/master/resources/file-sharing.yaml). |
| 9 | + |
| 10 | +There is an example implementation of such a service in the [jitsi-meet-file-sharing](https://github.com/jitsi/jitsi-meet-file-sharing-service). |
| 11 | +That is a simple implementation using local filesystem storage. |
| 12 | + |
| 13 | +### Setup |
| 14 | + |
| 15 | +On an existing deployment or after installing jitsi-meet following the [Self-Hosting Guide](https://jitsi.org/qi) you need to install the file sharing service and configure jitsi-meet to use it. |
| 16 | + |
| 17 | +- Download and install nvm |
| 18 | +``` |
| 19 | +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash |
| 20 | +``` |
| 21 | + |
| 22 | +- Clone the repository and deploy the service |
| 23 | +```bash |
| 24 | +cd /srv |
| 25 | +git clone https://github.com/jitsi/jitsi-meet-file-sharing-service.git |
| 26 | +cd /srv/jitsi-meet-file-sharing-service |
| 27 | +nvm install |
| 28 | +nvm use |
| 29 | +./deploy.sh |
| 30 | +``` |
| 31 | + |
| 32 | +- Setup sign material for short-lived tokens |
| 33 | +```bash |
| 34 | +mkdir /etc/jitsi/file-sharing-service |
| 35 | +mkdir -p /var/www/jitsi-meet-file-sharing-service/uploads |
| 36 | +openssl genrsa -out /etc/jitsi/file-sharing-service/short_lived_token.key 2048 |
| 37 | +openssl rsa -in /etc/jitsi/file-sharing-service/short_lived_token.key -pubout -out /etc/jitsi/file-sharing-service/short_lived_token.pub |
| 38 | +ssh-keygen -f /etc/jitsi/file-sharing-service/short_lived_token.key -e -m pem > /etc/jitsi/file-sharing-service/short_lived_token.pem |
| 39 | +chmod g+r /etc/jitsi/file-sharing-service/short_lived_token.key |
| 40 | +chown root:prosody /etc/jitsi/file-sharing-service/short_lived_token.key |
| 41 | +``` |
| 42 | + |
| 43 | +- Enable short-lived token in your prosody config. |
| 44 | +Add its configuration to `/etc/prosody/conf.avail/your-domain.cfg.lua`: |
| 45 | +```lua |
| 46 | +short_lived_token = { |
| 47 | + issuer = 'prosody'; |
| 48 | + accepted_audiences = { 'file-sharing' }; |
| 49 | + key_path = '/etc/jitsi/file-sharing-service/short_lived_token.key'; |
| 50 | + key_id = 'jitsi/short_lived_token_2025'; |
| 51 | + ttl_seconds = 30; |
| 52 | +}; |
| 53 | +``` |
| 54 | +Enable it in the `modules_enabled` section under the main virtual host: |
| 55 | +```lua |
| 56 | +modules_enabled = { |
| 57 | + ... |
| 58 | + 'short_lived_token'; |
| 59 | + ... |
| 60 | +}; |
| 61 | +``` |
| 62 | + |
| 63 | +- restart prosody: |
| 64 | +```bash |
| 65 | +systemctl restart prosody |
| 66 | +``` |
| 67 | + |
| 68 | +- Configure the file sharing service in config.js, add to the end: |
| 69 | +```javascript |
| 70 | +config.fileSharing = { |
| 71 | + apiUrl :"https://your-domain/file-service/v1/documents", |
| 72 | + enabled: true, |
| 73 | +}; |
| 74 | +``` |
| 75 | + |
| 76 | +Configure nginx by adding the following to your nginx configuration file (e.g., `/etc/nginx/sites-available/your-domain.conf`): |
| 77 | +```nginx |
| 78 | + client_max_body_size 50M; |
| 79 | + location ^~ /file-service/ { |
| 80 | + # Remove /file-service prefix when forwarding |
| 81 | + rewrite ^/file-service(/.*)$ $1 break; |
| 82 | +
|
| 83 | + # Add CORS headers |
| 84 | + add_header Access-Control-Allow-Origin "$http_origin" always; |
| 85 | + add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; |
| 86 | + add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With" always; |
| 87 | + add_header Access-Control-Allow-Credentials "true" always; |
| 88 | +
|
| 89 | + # Handle preflight requests |
| 90 | + if ($request_method = OPTIONS) { |
| 91 | + return 204; |
| 92 | + } |
| 93 | +
|
| 94 | + proxy_pass http://localhost:3000/; |
| 95 | + proxy_http_version 1.1; |
| 96 | + proxy_set_header Upgrade $http_upgrade; |
| 97 | + proxy_set_header Connection 'upgrade'; |
| 98 | + proxy_set_header Host $host; |
| 99 | + proxy_set_header X-Real-IP $remote_addr; |
| 100 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 101 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 102 | + proxy_cache_bypass $http_upgrade; |
| 103 | + proxy_connect_timeout 60s; |
| 104 | + proxy_send_timeout 60s; |
| 105 | + proxy_read_timeout 60s; |
| 106 | + } |
| 107 | +``` |
| 108 | +- restart nginx |
| 109 | +```bash |
| 110 | +systemctl restart nginx |
| 111 | +``` |
| 112 | + |
| 113 | +- Setup the environment variables for the file sharing service in `/srv/jitsi-meet-file-sharing-service/.env`: |
| 114 | +```bash |
| 115 | +JWT_PUBLIC_KEY_PATH=/etc/jitsi/file-sharing-service/short_lived_token.pem |
| 116 | +UPLOAD_DIR=/var/www/jitsi-meet-file-sharing-service/uploads |
| 117 | +``` |
| 118 | + |
| 119 | +- restart the file sharing service: |
| 120 | +```bash |
| 121 | +cd /srv/jitsi-meet-file-sharing-service |
| 122 | +nvm use |
| 123 | +pm2 delete jitsi-meet-file-sharing-service |
| 124 | +pm2 start ecosystem.config.js --env production |
| 125 | +``` |
| 126 | + |
| 127 | +- If you are using jwt authentication, make sure you pass 'file-upload' feature in user.context.features. |
| 128 | +- If you are using some other authentication method, you need to configure jitsi_default_permissions to include it. |
| 129 | +``` |
| 130 | +jitsi_default_permissions = { |
| 131 | + livestreaming = true; |
| 132 | + recording = true; |
| 133 | + transcription = true; |
| 134 | + ['outbound-call'] = true; |
| 135 | + ['create-polls'] = true; |
| 136 | + ['file-upload'] = true; |
| 137 | + ['send-groupchat'] = true; |
| 138 | + flip = true; |
| 139 | + }; |
| 140 | +``` |
| 141 | +If you change prosody configuration, make sure to restart it. |
| 142 | + |
| 143 | +### Usage |
| 144 | + |
| 145 | + - To rebuild the app: `npm run build` |
| 146 | + |
| 147 | + - To restart the service: `pm2 restart file-sharing-service` |
| 148 | + |
| 149 | + - To watch the logs: `pm2 logs file-sharing-service` |
| 150 | + |
| 151 | + |
0 commit comments