Seafile 12 Wiki 404

:slight_smile: just installed a fresh docker deployed instance of seafile CE 12 following this documentation: https :// manual . seafile . com / 12.0/setup/setup_ce_by_docker/

Apologies in advance, when I tried to save this post, it said “you cannot add links”, which is why I reformated URLs.

Brief problem description
Seafile itself works quite nice and I can upload files successfully.
However, the wiki isn’t working. The ui simply shows a popup saying “error” at the top and in the JS console, I can see

Failed to load resource: the server responded with a status of 404 (Not Found)

while trying to access

https :// foo.bar.com / sdoc-server / api/v1/docs/<HASH>/

Detailed Description
I already have a reverse proxy running on my server and initially I tried to compose seafile with its own reverse proxy cady. So: web -> nginx -> caddy -> seafile.

Then I found this article https :// forum. seafile. com /t/err-too-many-redirects-with-nginx-and-custom-seafile-ports/23362 which suggests to get rid of caddy entirely, which I did and it works.

Here are the changes I’ve made

Disable Caddy
I removed caddy.yml from the COMPOSE_FILE variable in the .env file in order to disable the caddy service.

Dot env file

COMPOSE_FILE='seafile-server.yml,seadoc.yml'
COMPOSE_PATH_SEPARATOR=','
...
SEAFILE_SERVER_HOSTNAME=foo.bar.com
SEAFILE_SERVER_PROTOCOL=https
...
ENABLE_SEADOC=true

seahub settings

CSRF_TRUSTED_ORIGINS = ['https://foo.bar.com']

Port 80 for seafile service
I modified seafile-server.yml to map port 80

  seafile:
    image: ${SEAFILE_IMAGE:-seafileltd/seafile-mc:12.0-latest}
    container_name: seafile
    ports:
      - "172.17.0.1:8877:80"

Port 80 for seadoc service

  seadoc:
    image: ${SEADOC_IMAGE:-seafileltd/sdoc-server:1.0-latest}
    container_name: seadoc
    volumes:
      - ${SEADOC_VOLUME:-/opt/seadoc-data/}:/shared
    ports:
      - "172.17.0.1:8866:80"

Nginx
Here are the modifications that I made to my “old” reverse proxy:

  server {
    listen         443 ssl;
    server_name    foo.bar.com;
    ssl_certificate SNIP;
    ssl_certificate_key SNIP;
    location / {
      proxy_read_timeout 310s;
      proxy_set_header Host $host;
      proxy_pass http://172.17.0.1:8877/;
      proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Connection "";
      proxy_http_version 1.1;
      client_max_body_size 0;
    }
    location /sdoc-server {
      proxy_read_timeout 310s;
      proxy_set_header Host $host;
      proxy_pass http://172.17.0.1:8866/;
      proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Connection "";
      proxy_http_version 1.1;
      client_max_body_size 0;
    }
    location /socket.io {
      proxy_read_timeout 310s;
      proxy_set_header Host $host;
      proxy_pass http://172.17.0.1:8866/;
      proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Connection "";
      proxy_http_version 1.1;
      client_max_body_size 0;
    }

So in essence everything / routed to the seafile service (port 8877) and everything /sdoc-server and /socket.io to the seadoc service.

If I click on the wiki, a new tab opens and the small popup opens at the top saying “error”. The Console says Failed to load resource: the server responded with a status of 404 (Not Found). If I manually click on the URL shown next to it (https://foo.bar.com/sdoc-server/api/v1/docs/<HASH>/) I get this error message: {"error_msg":"You don't have permission to access."}

Update*:
Seadoc doesn’t work either - I just learned what seadoc actually is, didn’t know about that specific *.sdoc format and associated editor.
When I create an *.sdoc inside a library and try to open it, I get this body:

Load doc content error

Console:

code ERR_BAD_REQUEST
...
message Request failed with status code 404
...
url "https://foo.bar.com/sdoc-server/api/v1/docs/54c5b33e-b6a1-4a2a-bbd3-a89e763d8aee/"
...
data Cannot GET //api/v1/docs/54c5b33e-b6a1-4a2a-bbd3-a89e763d8aee

:slight_smile: got it to work.
The nginx rules were wrong and I should’ve read the docs better, because the admin doc specifically mentions nginx rules for all services.

https://manual.seafile.com/12.0/setup/use_other_reverse_proxy/#add-reverse-proxy-for-related-services

From the doc for the seadoc service

location /sdoc-server/ {
    proxy_pass         http://127.0.0.1:8888/;
    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;

    client_max_body_size 100m;
}

location /socket.io {
    proxy_pass http://127.0.0.1:8888;
    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;
}

Notable difference, which was probably the cause:

location /sdoc-server/ {
  proxy_pass         http://127.0.0.1:8888/;

=> I didn’t have that trailing slash