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 中。
            
                
                
# Enable Office Online Server
ENABLE_OFFICE_WEB_APP = True

# Url of Office Online Server's discovery page
# The discovery page tells Seafile how to interact with Office Online Server when view file online
# You should change `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'

# Expiration of WOPI access token
# WOPI access token is a string used by Seafile to determine the file's
# identity and permissions when use Office Online Server view it online
# And for security reason, this token should expire after a set time period
WOPI_ACCESS_TOKEN_EXPIRATION = 60 * 60 * 24 # seconds

# List of file formats that you want to view through Office Online Server
# You can change this value according to your preferences
# And of course you should make sure your Office Online Server supports to preview
# the files with the specified extensions
OFFICE_WEB_APP_FILE_EXTENSION = ('ods', 'xls', 'xlsb', 'xlsm', 'xlsx','ppsx', 'ppt',
     'pptm', 'pptx', 'doc', 'docm', 'docx')

# Enable edit files through Office Online Server
ENABLE_OFFICE_WEB_APP_EDIT = True

# types of files should be editable through Office Online Server
# Note, Office Online Server 2016 is needed for editing docx
OFFICE_WEB_APP_EDIT_FILE_EXTENSION = ('xlsx', 'pptx', 'docx')


# HTTPS authentication related (optional)

# Server certificates
# Path to a CA_BUNDLE file or directory with certificates of trusted CAs
# NOTE: If set this setting to a directory, the directory must have been processed using the c_rehash utility supplied with OpenSSL.
OFFICE_WEB_APP_SERVER_CA = '/path/to/certfile'


# Client certificates
# You can specify a single file (containing the private key and the certificate) to use as client side certificate
OFFICE_WEB_APP_CLIENT_PEM = 'path/to/client.pem'

# or you can specify these two file path to use as client side certificate
OFFICE_WEB_APP_CLIENT_CERT = 'path/to/client.cert'
OFFICE_WEB_APP_CLIENT_KEY = 'path/to/client.key'
然后重启服务
            
                
                
./seafile.sh restart
./seahub.sh restart
单击您在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 请求时可能会随机异常终止。