Using Seafile internally and externally

I’m running Seafile 13 via Docker behind a firewall with NAT. I’d like to use the application both internally and externally. Accessing the URL (e.g., https://docs.domain.tld) works without any issues if I run one domain name server for the external address and one for the internal address.

However, this isn’t straightforward with SeaDoc: the running container accesses the internal DNS and thus returns the internal IP address for the URL https://docs.domain.tld. This works fine when working internally, but SeaDoc doesn’t work when working externally. In that case, the external IP address should be used. However, I can’t tell within the Docker container whether the internal or external IP address is needed. And even if I could, I don’t know of a way to use different DNS servers in different scenarios.

How can this be solved? I have the same problem when accessing Collabora Online or OnlyOffice.

In Seafile, integration containers such as SeaDoc, Collabora Online, and OnlyOffice do not inspect the client’s network location or return internal IP addresses to the client.

Here is how the communication flow works:

  1. When a user opens an office or SeaDoc file, Seahub sends a webpage containing an iframe or script URL pointing to the configured domain name (e.g., https://docs.domain.tld/sdoc-server/ or your Collabora/OnlyOffice URL).
  2. The client’s own browser resolves that domain name using its configured DNS resolver. Internal clients query your internal DNS and receive the LAN IP, while external clients query public DNS and receive your external IP.
  3. The containers never need to dynamically switch DNS servers or determine whether a client is internal or external.

If SeaDoc, Collabora, or OnlyOffice works internally but fails externally, the cause usually stems from one of the following:

  1. Configured Service URLs: Ensure that service URLs (e.g., SEADOC_SERVER_URL in .env, or OFFICE_WEB_APP_BASE_URL in seahub_settings.py) are configured using your unified domain name (https://docs.domain.tld/...) rather than internal IP addresses or internal hostnames.

  2. External Firewall Port Forwarding and Reverse Proxy:

    • SeaDoc: SeaDoc is routed via reverse proxy under /sdoc-server/ and /socket.io/. Make sure your external reverse proxy forwards WebSocket connections (/socket.io/) properly to the SeaDoc service on HTTPS (port 443). Refer to the SeaDoc integration documentation: SeaDoc Integration - Seafile Admin Manual
    • Collabora Online / OnlyOffice: Collabora typically listens on port 6232 (or port 9980) unless it is placed behind the same reverse proxy on port 443. If external users connect directly to that port, it must be forwarded through your NAT firewall. If you are reverse-proxying Collabora/OnlyOffice under HTTPS port 443, ensure your public proxy configuration includes the necessary WOPI/WebSocket headers. Refer to the Collabora integration documentation: Collabora Online Integration - Seafile Admin Manual
  3. Container-to-Host Communication: Both Collabora and OnlyOffice containers must be able to contact Seafile to download document contents. When containers query your internal DNS, ensure they can reach https://docs.domain.tld either directly or via the local network without being blocked by NAT reflection/hairpinning issues.

Using a single unified FQDN (docs.domain.tld) across both internal and external DNS is the standard and recommended setup. Once the firewall forwarding and reverse proxy routing are properly aligned, external clients will reach the document servers seamlessly.

That’s the best explanation I’ve ever read on this topic. Thank you very much!

If the manual had explained it that way, I would have understood a lot of things much better in the past. Please post this explanation right there — thank you.

It’s really interesting, I ran another test, and it turns out everything works, both internally and externally. Fantastic!