Seafile 集成 Collabora Online (LibreOffice Online)

从 Seafile 专业版 6.0.0 开始,可以选择集成 Collabora Online 到 Seafile 系统中以实现 office 文档的在线预览以及在线编辑功能。

安装 LibreOffice Online

  • 准备一台安装有 docker 的 Ubuntu 16.04 64位 服务器;

  • 提供一个域名给这个服务器,这里我们使用 collabora-online.seafile.com

  • 获得并且安装一个可用 TLS/SSL 证书到该服务器上,我们使用 Let’s Encrypt

  • 使用 Nginx 服务代理 collabora online,配置示例如下:

  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. }
  • 然后使用下边的命令来启动 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

注意domain参数是你的Seafile Server的域名,假如你的Seafile Server的域名是 demo.seafile.com,那这个命令应该:

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

更多关于Collabora Online的信息和如何部署它请参考 https://www.collaboraoffice.com

配置 Seafile

注意:你必须在Seafile上 enable https 来使用 Collabora Online,如何获得可用的TLS/SSL证书?(我们使用 Let’s Encrypt)

添加以下配置到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')

然后重启 Seafile。

在 Seafile Web 界面上点击一个office文件,你将会看到如下页面:

LibreOffice-online

问题解决:

了解如何集成工作将帮助你调试问题,当用户访问文件页面时:

  • (seahub->browser) Seahub将生成一个包含iframe的页面,并将其发送到浏览器。
  • (browser->LibreOffice Online) 使用iframe,浏览器将尝试从LibreOffice在线加载文件预览页面。
  • (LibreOffice Online->seahub) LibreOffice Online 接收请求并发送请求到Seahub获取文件内容。
  • (LibreOffice Online->browser) LibreOffice Online 将文件预览页面发送到浏览器。
    如果你有问题,请检查Nginx中与Seahub相关的日志和 Collabora Online。

原文: https://manual-cn.seafile.com/deploy/libreoffice_online.html