Skip to content

Commit

Permalink
Merge pull request #408 from haiwen/update_12.0_cluster_deployment
Browse files Browse the repository at this point in the history
opt: cluster deployments and seadoc
  • Loading branch information
freeplant authored Nov 25, 2024
2 parents b2b2419 + 2b443a5 commit 99d541f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 124 deletions.
193 changes: 72 additions & 121 deletions manual/extension/setup_seadoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,33 @@ SeaDoc has the following deployment methods with different situations:
- Same host with Seafile server cluster (frontend node)
- Same host with Seafile server deploy from binary packages

=== "Situation 1"
Download the `seadoc.yml` and integrate SeaDoc in Seafile docker.
### SeaDoc and Seafile docker (single-node mode) are deployed on the same host

1. Download the `seadoc.yml` and integrate SeaDoc in Seafile docker.

```shell
wget https://manual.seafile.com/12.0/docker/seadoc.yml
```

Modify `.env`, and insert `seadoc.yml` into `COMPOSE_FILE`, and enable SeaDoc server
2. Modify `.env`, and insert `seadoc.yml` into `COMPOSE_FILE`, and enable SeaDoc server

```shell
COMPOSE_FILE='seafile-server.yml,caddy.yml,seadoc.yml'
ENABLE_SEADOC=true
SEADOC_SERVER_URL=https://example.seafile.com/sdoc-server
SEADOC_SERVER_URL=https://seafile.example.com/sdoc-server
```
=== "Situation 2"

Download and modify the `.env` and `seadoc.yml` files.
### SeaDoc deploys on a new host or the same host with Seafile server (cluster and standalone)

1. Download and modify the `.env` and `seadoc.yml` files.

```sh
wget https://manual.seafile.com/12.0/docker/seadoc/1.0/standalone/seadoc.yml
wget -O .env https://manual.seafile.com/12.0/docker/seadoc/1.0/standalone/env
```
Then modify the `.env` file according to your environment. The following fields are needed to be modified:

2. Then modify the `.env` file according to your environment. The following fields are needed to be modified:

| variable | description |
|------------------------|---------------------------------------------------------------------------------------------------------------|
Expand All @@ -76,129 +79,77 @@ SeaDoc has the following deployment methods with different situations:
| `SEAFILE_SERVER_HOSTNAME`| Seafile host name |
| `SEAFILE_SERVER_PROTOCOL`| http or https |

!!! note
By default, SeaDoc server listens to port `80`. If SeaDoc is deployed on the same machine as Seafile server (including deploying from binary packages and Seafile cluster mode), you need to change the **listening port of SeaDoc server** or **set up a proxy** for SeaDoc server.

=== "Modify listening port"

Modify `seadoc.yml`

```yml
services:
seadoc:
...
ports:
- "<your SeaDoc server port>:80"
...
```

Now your `SEADOC_SERVER_URL` should be:
```
{SEAFILE_SERVER_PROTOCOL}://{SEAFILE_SERVER_HOSTNAME}:<your SeaDoc server port>
```
=== "set up a proxy"

Modify `seafile.nginx.conf`

=== "Seafile cluster"

```
location /sdoc-server/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
return 204;
}

proxy_pass http://sdoc-server:80/;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 100m;
}

location /socket.io {
proxy_pass http://sdoc-server:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_redirect off;

proxy_buffers 8 32k;
proxy_buffer_size 64k;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
```

=== "Seafile deploy from binary packages"

```
location /sdoc-server/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
return 204;
}

proxy_pass http://127.0.0.1:80/;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 100m;
}

location /socket.io {
proxy_pass http://127.0.0.1:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_redirect off;

proxy_buffers 8 32k;
proxy_buffer_size 64k;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
```
Now your `SEADOC_SERVER_URL` should be:
```
{SEAFILE_SERVER_PROTOCOL}://{SEAFILE_SERVER_HOSTNAME}/sdoc-server/
```
3. By default, SeaDoc server listens to port 80. If the port is already taken by another service (e.g., deploy SeaDoc on the same machine where Seafile server is running), ***you have to change the listening port of SeaDoc***:


Modify `seadoc.yml`

```yml
services:
seadoc:
...
ports:
- "<your SeaDoc server port>:80"
...
```

4. Modify `seafile.nginx.conf` to setup reverse proxy, **please replace `127.0.0.1:80` to `host:port` of your Seadoc server**

```
location /sdoc-server/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
return 204;
}

proxy_pass http://127.0.0.1:80/;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 100m;
}

location /socket.io {
proxy_pass http://127.0.01:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_redirect off;

proxy_buffers 8 32k;
proxy_buffer_size 64k;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
```
Now your `SEADOC_SERVER_URL` should be:
```sh
{SEAFILE_SERVER_PROTOCOL}://{SEAFILE_SERVER_HOSTNAME}/sdoc-server/

#e.g., https://seafile.example.com/sdoc-server/
```
## Start SeaDoc server
Start SeaDoc server with the following command
```sh
docker compose up -d
```


Now you can use SeaDoc!
## SeaDoc directory structure
Expand Down
24 changes: 21 additions & 3 deletions manual/setup/cluster_deploy_with_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We assume you have already deployed memcache, MariaDB, ElasticSearch in separate

## Deploy Seafile service

### Deploy seafile frontend nodes
### Deploy the first Seafile frontend node

1. Create the mount directory

Expand Down Expand Up @@ -124,9 +124,14 @@ We assume you have already deployed memcache, MariaDB, ElasticSearch in separate
- `INIT_S3_KEY_ID`
- `INIT_S3_SECRET_KEY`
8. (Optional) You can follow [here](../extension/setup_seadoc.md#deployment-method) to deploy SeaDoc server (please refer ***Situation 2***). And then modify `SEADOC_SERVER_URL` in your `.env` file
!!! tip
We recommend that you check that the relevant configuration files are correct and copy the `SEAFILE_VOLUME` directory before the service is officially started, because only the configuration files are generated after initialization. You can directly migrate the entire copied `SEAFILE_VOLUME` to other nodes later:
```sh
cp -r /opt/seafile/shared /opt/seafile/shared-bak
```
9. Restart the container to start the service in frontend node
8. Restart the container to start the service in frontend node
```sh
docker compose down
Expand Down Expand Up @@ -165,6 +170,15 @@ We assume you have already deployed memcache, MariaDB, ElasticSearch in separate
Done.
```
### Deploy the others Seafile frontend nodes
You can directly copy all the directories generated by the first frontend node, including the Docker-compose files (e.g., `seafile-server.yml`, `.env`) and modified configuration files, and then start the seafile docker container:
```sh
docker compose down
docker compose up -d
```
### Deploy seafile backend node
1. Create the mount directory
Expand Down Expand Up @@ -343,3 +357,7 @@ $ systemctl enable --now keepalived
```
So far, Seafile cluster has been deployed.
## (Optional) Deploy SeaDoc server
You can follow [here](../extension/setup_seadoc.md) to deploy SeaDoc server. And then modify `SEADOC_SERVER_URL` in your `.env` file

0 comments on commit 99d541f

Please sign in to comment.