Skip to content

Seadoc - gen_file_get_url always returns external base URL #8100

@zhengliw

Description

@zhengliw

Brief summary: When running the Seafile stack in Docker with the official instructions (https://manual.seafile.com/13.0/setup/setup_ce_by_docker/#download-and-modify-env), Seadoc will not work out of the box for some network environments. It will show 加载文档内容错误 (Load doc content failed).

After through investigation this afternoon, there are (at least?) two hurdles to overcome to make Seadoc work:

  1. When a Seadoc file is opened, Seadoc tries to get the download URL of the file from Seahub (relevant file and line). The base URL it uses is defined in the variable SEAHUB_SERVER, which is often set to the external URL of the Seafile/Seahub instance. But due to many factors (DNS, lack of Hairpin NAT, Docker bridge networks without IPv6), Seadoc can't directly access it from inside the container. As a workaround, we can configure Seadoc to access the Seahub container on the same Docker bridge network by setting the following undocumented environment variable:
    SEAHUB_SERVICE_URL="http://seafile"
    This environment variable is accessed in a configuration component of Seadoc.

  2. Seahub, however, always returns a download URL with the external base URL and the HTTPS prefix as set in environment variables on installation. This behavior can't be changed easily by an admin as it would require modifications to the code.

But that's why I opened this issue. :) I think it would be great to change relevant code parts so that not the hardcoded base URL is returned. We could infer the base URL by looking at the protocol (HTTP/HTTPS?) and the host header of the request, so that base URL becomes "${protocol}://${host}". Or easier yet, we could just use the environment variable as defined above, SEAHUB_SERVICE_URL, as the base URL for Seadoc relevant parts.

I could try to implement a proof-of-concept and PR, but I'd like to know your thoughts on this first.

最后:感谢Seafile团队为自托管社区带来了一套如此优秀的软件,阿里出来的团队果然厉害的~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions