Office Online Server 集成

在Seafile专业版 4.4.0(或更高版本)中,可以使用 Microsoft Office Online Server (以前命名为Office Web Apps)在线预览文档。 Office Online Server 为所有的 Office 文档提供最佳预览。它还支持直接在web浏览器中协作编辑Office文件。对于拥有 Microsoft Office 批量许可证的组织,可以免费使用Office Online Server。有关 Office Online Server 的更多信息以及如何部署Office Online Server,请参阅 https://technet.microsoft.com/zh-cn/library/jj219455(v=office.16).aspx.

注意:仅支持 Office Online Server 2016 及其以上版本。

Seafile自身的Office文件预览仍然是默认的。使用 Office Online Server 进行预览,请添加以下配置项到 seahub_settings.py 中。

  1. # Enable Office Online Server
  2. ENABLE_OFFICE_WEB_APP = True
  3. # Url of Office Online Server's discovery page
  4. # The discovery page tells Seafile how to interact with Office Online Server when view file online
  5. # You should change `http://example.office-web-app.com` to your actual Office Online Server server address
  6. OFFICE_WEB_APP_BASE_URL = 'http://example.office-web-app.com/hosting/discovery'
  7. # Expiration of WOPI access token
  8. # WOPI access token is a string used by Seafile to determine the file's
  9. # identity and permissions when use Office Online Server view it online
  10. # And for security reason, this token should expire after a set time period
  11. WOPI_ACCESS_TOKEN_EXPIRATION = 30 * 60 # seconds
  12. # List of file formats that you want to view through Office Online Server
  13. # You can change this value according to your preferences
  14. # And of course you should make sure your Office Online Server supports to preview
  15. # the files with the specified extensions
  16. OFFICE_WEB_APP_FILE_EXTENSION = ('ods', 'xls', 'xlsb', 'xlsm', 'xlsx','ppsx', 'ppt',
  17. 'pptm', 'pptx', 'doc', 'docm', 'docx')
  18. # Enable edit files through Office Online Server
  19. ENABLE_OFFICE_WEB_APP_EDIT = True
  20. # types of files should be editable through Office Online Server
  21. # Note, Office Online Server 2016 is needed for editing docx
  22. OFFICE_WEB_APP_EDIT_FILE_EXTENSION = ('xlsx', 'pptx', 'docx')
  23. # HTTPS authentication related (optional)
  24. # Server certificates
  25. # Path to a CA_BUNDLE file or directory with certificates of trusted CAs
  26. # NOTE: If set this setting to a directory, the directory must have been processed using the c_rehash utility supplied with OpenSSL.
  27. OFFICE_WEB_APP_SERVER_CA = '/path/to/certfile'
  28. # Client certificates
  29. # You can specify a single file (containing the private key and the certificate) to use as client side certificate
  30. OFFICE_WEB_APP_CLIENT_PEM = 'path/to/client.pem'
  31. # or you can specify these two file path to use as client side certificate
  32. OFFICE_WEB_APP_CLIENT_CERT = 'path/to/client.cert'
  33. OFFICE_WEB_APP_CLIENT_KEY = 'path/to/client.key'

然后重启服务

  1. ./seafile.sh restart
  2. ./seahub.sh restart

单击您在seahub_sttings.py中指定的文档后,您将看到新的预览页面。

office-web-app

故障排查

了解Web应用集成原理将帮助你排查问题。当用户访问页面时:

  1. (seahub->浏览器) Seahub 将生成一个包含 iframe 的页面并将其发送到浏览器。
  2. (浏览器->office web app) 使用 iframe,浏览器将尝试从 office online server 加载预览页面。
  3. (office online server->seahub) office online server 接收请求并向 Seahub 发送请求以获取文件内容。
  4. (office online server->浏览器) office online server 发送文件预览页面给浏览器。

请检查Seahub的Nginx日志(步骤3)和 office online server,以查看哪个步骤出错。

注意在 Windows 上的分页文件

您应该确保在您的Windows系统中至少配置了几GB的分页文件。否则,IIS工作进程在处理Office在线请求时可能会随机死亡。