遇到个项目需要用到office协作,找了一圈nc比较合适,就开工了
环境:httpd 2.4.5 and later
php7 or later
安装mod_proxy
yum -y install mod_proxy_uwsgi mod_proxy_html
安装docker
yum -y install docker
参考:https://nextcloud.com/collaboraonline/
开始用docker安装collaboraonline,
docker pull collabora/code
这里遇到报错:Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
结果是docker服务没启动,跑起来:service docker start
再pull,成功
最后会得到:Status: Downloaded newer image for docker.io/collabora/code:latest
接下来,用你喜欢的方式,创建反向代理,conf文件内容如下:
<VirtualHost *:443>
#ServerName改成collabora服务实际运行的域名,一般和nextcloud不同
ServerName yourfiles.yourdomain.com:443
# SSL configuration, you may want to take the easy route instead and use Lets Encrypt!
SSLEngine on
#签名证书位置
SSLCertificateFile /path/to/signed_certificate
#中间证书位置
SSLCertificateChainFile /path/to/intermediate_certificate
#私钥
SSLCertificateKeyFile /path/to/private/key
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
SSLHonorCipherOrder on
# Encoded slashes need to be allowed
AllowEncodedSlashes NoDecode
# Container uses a unique non-signed certificate
SSLProxyEngine On
SSLProxyVerify None
#下面这2行如果引起报错 ,可以注释掉,测过不影响,因为前面已经禁用SSLProxyVerify,不知道为什么还要画蛇添足
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off
# keep the host
ProxyPreserveHost On
# static html, js, images, etc. served from loolwsd
# loleaflet is the client part of LibreOffice Online
ProxyPass /loleaflet https://127.0.0.1:9980/loleaflet retry=0
ProxyPassReverse /loleaflet https://127.0.0.1:9980/loleaflet
# WOPI discovery URL
ProxyPass /hosting/discovery https://127.0.0.1:9980/hosting/discovery retry=0
ProxyPassReverse /hosting/discovery https://127.0.0.1:9980/hosting/discovery
# Main websocket
ProxyPassMatch "/lool/(.*)/ws$" wss://127.0.0.1:9980/lool/$1/ws nocanon
# Admin Console websocket
ProxyPass /lool/adminws wss://127.0.0.1:9980/lool/adminws
# Download as, Fullscreen presentation and Image upload operations
ProxyPass /lool https://127.0.0.1:9980/lool
ProxyPassReverse /lool https://127.0.0.1:9980/lool
</VirtualHost>
然后,就可以把docker跑起来了,先给docker加上开机启动
ckhconfig docker on
再把容器跑起来:
docker run -t -d -p 127.0.0.1:9980:9980 -e ‘domain=nextcloud\\.yourdomain\\.com’ -e “username=username” -e “password=password” –restart always –cap-add MKNOD collabora/code
这里的domain,是nextcloud运行的domain,需要用\\转义.,-p后面绑定在127.0.0.1是为了安全,因为最后是用反向代理对nc使用的,测试期间可以不加ip,就绑定在所有IP了
username和password是指定管理后台的用户名和密码,之前没有指定走了不少弯路,虽然这个后台在正常使用后不会再被用到,配置过程中也其实是不需要用的。
运行后会得到一个容器id,然后netstat看一下
netstat -an|grep 9980
有listening,就可以下一步了
先打开后台,看下有没有什么问题https://yourfiles.yourdomain.com/loleaflet/dist/admin/admin.html
如果登陆后有404,或者任何错误,可能是Apache版本不够高,不支持websock反向代理,自己换Apache吧,最低版本要求是2.4.5或者换nginx
nextcloud的安装就非常简单了,wget到服务器,unzip解包,按流程安装,完
接下来,在应用>office&text中启用Collabora Online
然后到设置》在线协作中,填入之前配置的Collabora Online地址,完工