-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
99 lines (76 loc) · 2.55 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Real-time Spreadsheet Collaboration with Jspreadsheet and Nginx
The Jspreadsheet Server extension is a JavaScript plugin that facilitates real-time data sharing and persistence within Jspreadsheet. It operates through a WebSocket-based service that runs on your server, enabling collaborative and interactive spreadsheet operations while ensuring complete data control.
## Requirements
- PM2
- Node.js
- Nginx
## Tutorial
This tutorial explains how to install Jspreadsheet on your Linux server using Nginx.
### Step 1: Clone the project
```bash
git clone https://github.com/jspreadsheet/server.git /var/lib/server```
### Step 2: Install dependencies
Navigate to the server directory and install the required Node.js packages:
cd /var/lib/server\
npm install
### Step 3: Start the application with PM2
pm2 start src/index.js
### Step 4: Configure Nginx
Edit your domain's Nginx configuration file:\
vi /etc/nginx/conf.d/yourdomain.com.conf
Add the following server block to the configuration file:\
```
server {
listen 443;
// ... other configuration ...
location /server/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Nginx-Proxy true;
proxy_pass_request_headers on;
proxy_pass http://server/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
if ($http_origin) {
add_header 'Access-Control-Allow-Origin' '*';
}
}
}
upstream server {
server 127.0.0.1:3000;
keepalive 15;
}
```
### Step 5: Restart Nginx
service nginx restart
Now, the server will respond on port 80 of your domain.
## Client Setup
Here's how you can set up the client:
```
// Set the license for both the plugin and the spreadsheet
jspreadsheet.setLicense('your-license-here');
// Set the extensions
jspreadsheet.setExtensions({ client });
// Connect to the server
let remote = client.connect({
url: 'https://yourdomain.com',
path: 'server/',
token: 'user-identifier-jwt' // Token for user validation
});
// Create a new spreadsheet if it does not exist
remote.create('53aa4c90-791d-4a65-84a6-8ac25d6b1104', {
tabs: true,
toolbar: true,
worksheets: [{
minDimensions: [4, 4]
}]
});
// Connect to a spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
guid: '53aa4c90-791d-4a65-84a6-8ac25d6b1104'
});
```