Integrate Seafile with Collabora Online (LibreOffice Online)

Since Seafile Professional edition 6.0.0, you can integrate Seafile with Collabora Online to preview office files.

Setup LibreOffice Online

  1. Prepare an Ubuntu 16.04 64bit server with docker installed;

  2. Assign a domain name to this server, we use collabora-online.seafile.com here.

  3. Obtain and install valid TLS/SSL certificates for this server, we use Let’s Encrypt.

  4. Use Nginx to serve collabora online, config file example:

    1. server {
    2. listen 443 ssl;
    3. server_name collabora-online.seafile.com;
    4. ssl_certificate /etc/letsencrypt/live/collabora-online.seafile.com/fullchain.pem;
    5. ssl_certificate_key /etc/letsencrypt/live/collabora-online.seafile.com/privkey.pem;
    6. # static files
    7. location ^~ /loleaflet {
    8. proxy_pass https://localhost:9980;
    9. proxy_set_header Host $http_host;
    10. }
    11. # WOPI discovery URL
    12. location ^~ /hosting/discovery {
    13. proxy_pass https://localhost:9980;
    14. proxy_set_header Host $http_host;
    15. }
    16. # websockets, download, presentation and image upload
    17. location ^~ /lool {
    18. proxy_pass https://localhost:9980;
    19. proxy_set_header Upgrade $http_upgrade;
    20. proxy_set_header Connection "upgrade";
    21. proxy_set_header Host $http_host;
    22. }
    23. }
  5. then use the following command to setup/start Collabora Online:

    1. docker pull collabora/code
    2. docker run -t -p 9980:9980 -e "domain=<your-dot-escaped-domain>" --restart always --cap-add MKNOD collabora/code

    NOTE: the domain args is the domain name of your Seafile server, if your
    Seafile server’s domain name is demo.seafile.com, the command should be:

    1. docker run -t -p 9980:9980 -e "domain=demo\.seafile\.com" --restart always --cap-add MKNOD collabora/code

For more information about Collabora Online and how to deploy it, please refer to https://www.collaboraoffice.com

Config Seafile

NOTE: You must enable https with valid TLS/SSL certificates (we use Let’s Encrypt) to Seafile to use Collabora Online.

Add following config option to seahub_settings.py:

  1. # From 6.1.0 CE version on, Seafile support viewing/editing **doc**, **ppt**, **xls** files via LibreOffice
  2. # Add this setting to view/edit **doc**, **ppt**, **xls** files
  3. OFFICE_SERVER_TYPE = 'CollaboraOffice'
  4. # Enable LibreOffice Online
  5. ENABLE_OFFICE_WEB_APP = True
  6. # Url of LibreOffice Online's discovery page
  7. # The discovery page tells Seafile how to interact with LibreOffice Online when view file online
  8. # You should change `https://collabora-online.seafile.com/hosting/discovery` to your actual LibreOffice Online server address
  9. OFFICE_WEB_APP_BASE_URL = 'https://collabora-online.seafile.com/hosting/discovery'
  10. # Expiration of WOPI access token
  11. # WOPI access token is a string used by Seafile to determine the file's
  12. # identity and permissions when use LibreOffice Online view it online
  13. # And for security reason, this token should expire after a set time period
  14. WOPI_ACCESS_TOKEN_EXPIRATION = 30 * 60 # seconds
  15. # List of file formats that you want to view through LibreOffice Online
  16. # You can change this value according to your preferences
  17. # And of course you should make sure your LibreOffice Online supports to preview
  18. # the files with the specified extensions
  19. OFFICE_WEB_APP_FILE_EXTENSION = ('odp', 'ods', 'odt', 'xls', 'xlsb', 'xlsm', 'xlsx','ppsx', 'ppt', 'pptm', 'pptx', 'doc', 'docm', 'docx')
  20. # Enable edit files through LibreOffice Online
  21. ENABLE_OFFICE_WEB_APP_EDIT = True
  22. # types of files should be editable through LibreOffice Online
  23. OFFICE_WEB_APP_EDIT_FILE_EXTENSION = ('odp', 'ods', 'odt', 'xls', 'xlsb', 'xlsm', 'xlsx','ppsx', 'ppt', 'pptm', 'pptx', 'doc', 'docm', 'docx')

Then restart Seafile.

Click an office file in Seafile web interface, you will see the online preview rendered by LibreOffice online. Here is an example:

LibreOffice-online

Trouble shooting

Understanding how theintegration work will help you debug the problem. When a user visits a file page:

  1. (seahub->browser) Seahub will generate a page containing an iframe and send it to the browser
  2. (browser->LibreOffice Online) With the iframe, the browser will try to load the file preview page from the LibreOffice Online
  3. (LibreOffice Online->seahub) LibreOffice Online receives the request and sends a request to Seahub to get the file content
  4. (LibreOffice Online->browser) LibreOffice Online sends the file preview page to the browser.

If you have a problem, please check the Nginx log for Seahub (for step 3) and Collabora Online to see which step is wrong.