首先,啟動(dòng)onlyoffice的Docker鏡像,本文章采用的2023年11月初的官方鏡像,具體版本號未查到。當(dāng)時(shí)國內(nèi)的鏡像源只能下載到舊版本的,需要將/etc/docker/daemon.json設(shè)置"dns" : [ "8.8.8.8" ]方能下載。
先用docker exec進(jìn)入啟動(dòng)的onlyoffice鏡像,仿照如下帖子創(chuàng)建簽名
CentOS7自簽名SSL證書并給nginx配置https_ssl寫在nginx vhost中-CSDN博客
返回宿主機(jī),使用docker cp將簽名拷出,另外需從宿主機(jī)中找到ds-docservice.conf一同拷出。
需要配置nginx的配置文件ds.conf,代碼如下
ssl_certificate /etc/onlyoffice/documentserver/nginx/onlyoffice.crt; ssl_certificate_key /etc/onlyoffice/documentserver/nginx/onlyoffice.key; ssl_session_cache shared:SSL:1m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; set $secure_link_secret xtj7tj7DSqWKqqHM3e2P; include /etc/nginx/includes/ds-*.conf;
為解決410和403的問題,需找到鏡像中的ds-docservice.conf,注釋掉部分代碼,代碼如下
secure_link $arg_md5,$arg_expires; secure_link_md5 "$secure_link_expires$uri$secure_link_secret"; #if ($secure_link = "") { #if ($secure_link = "0") {
docker啟動(dòng)的映射路徑,配置如下
onlyoffice-documentserver: image: onlyoffice/documentserver:latest container_name: onlyoffice-documentserver JWT_SECRET: my_little_secret - ./data/onlyoffice-documentserver/onlyoffice.key:/etc/onlyoffice/documentserver/nginx/onlyoffice.key - ./data/onlyoffice-documentserver/onlyoffice.csr:/etc/onlyoffice/documentserver/nginx/onlyoffice.csr - ./data/onlyoffice-documentserver/onlyoffice.crt:/etc/onlyoffice/documentserver/nginx/onlyoffice.crt - ./data/onlyoffice-documentserver/ds.conf:/etc/onlyoffice/documentserver/nginx/ds.conf - ./data/onlyoffice-documentserver/ds-docservice.conf:/etc/onlyoffice/documentserver/nginx/includes/ds-docservice.conf
親測可用!
如此操作,瀏覽器會顯示“不安全”,如果有真實(shí)域名和CA證書,也可直接進(jìn)行配置,nginx.conf配置如下:
server_name chat.victorysoft.online; ssl_certificate /etc/onlyoffice/documentserver/nginx/xxx.xxx.xxx.pem; ssl_certificate_key /etc/onlyoffice/documentserver/nginx/xxx.xxx.xxx.key; ssl_session_cache shared:SSL:1m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; set $secure_link_secret xtj7tj7DSqWKqqHM3e2P; include /etc/nginx/includes/ds-*.conf;
|