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.
注意:Seafile 仅支持 Office Online Server 2016 及以上版本。
Seafile自身的Office文件预览仍然是默认的。使用 Office Online Server 进行预览,请添加以下配置项到 seahub_settings.py 中。
#EnableOfficeOnlineServer
ENABLE_OFFICE_WEB_APP=True

#UrlofOfficeOnlineServer'sdiscoverypage
#ThediscoverypagetellsSeafilehowtointeractwithOfficeOnlineServerwhenviewfileonline
#Youshouldchange`http://example.office-web-app.com` to your actual Office Online Server server address
OFFICE_WEB_APP_BASE_URL='http://example.office-web-app.com/hosting/discovery'

#ExpirationofWOPIaccesstoken
#WOPIaccesstokenisastringusedbySeafiletodeterminethefile's
#identityandpermissionswhenuseOfficeOnlineServerviewitonline
#Andforsecurityreason,thistokenshouldexpireafterasettimeperiod
WOPI_ACCESS_TOKEN_EXPIRATION=60*60*24#seconds

#ListoffileformatsthatyouwanttoviewthroughOfficeOnlineServer
#Youcanchangethisvalueaccordingtoyourpreferences
#AndofcourseyoushouldmakesureyourOfficeOnlineServersupportstopreview
#thefileswiththespecifiedextensions
OFFICE_WEB_APP_FILE_EXTENSION=('ods','xls','xlsb','xlsm','xlsx','ppsx','ppt',
    'pptm','pptx','doc','docm','docx')

#EnableeditfilesthroughOfficeOnlineServer
ENABLE_OFFICE_WEB_APP_EDIT=True

#typesoffilesshouldbeeditablethroughOfficeOnlineServer
#Note,OfficeOnlineServer2016isneededforeditingdocx
OFFICE_WEB_APP_EDIT_FILE_EXTENSION=('xlsx','pptx','docx')


#HTTPSauthenticationrelated(optional)

#Servercertificates
#PathtoaCA_BUNDLEfileordirectorywithcertificatesoftrustedCAs
#NOTE:Ifsetthissettingtoadirectory,thedirectorymusthavebeenprocessedusingthec_rehashutilitysuppliedwithOpenSSL.
OFFICE_WEB_APP_SERVER_CA='/path/to/certfile'


#Clientcertificates
#Youcanspecifyasinglefile(containingtheprivatekeyandthecertificate)touseasclientsidecertificate
OFFICE_WEB_APP_CLIENT_PEM='path/to/client.pem'

#oryoucanspecifythesetwofilepathtouseasclientsidecertificate
OFFICE_WEB_APP_CLIENT_CERT='path/to/client.cert'
OFFICE_WEB_APP_CLIENT_KEY='path/to/client.key'
然后重启服务
./seafile.shrestart
./seahub.shrestart
单击您在seahub_sttings.py中指定的文档后,您将看到新的预览页面。
故障排查
了解集成原理有助于排查问题。当用户访问文件页面时:
  1. (seahub -> 浏览器) Seahub 生成一个包含 iframe 的页面并返回给浏览器
  2. (浏览器 -> Office Online Server) 浏览器通过 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 系统中配置了至少几个 GB 的分页文件(paging file)。否则 IIS 工作进程在处理 Office Online 请求时可能会随机异常终止。