alist + onlyOffice
本文最后更新于 416 天前,其中的信息可能已经有所发展或是发生改变。

1、docker 安装onlyoffice 端口号注意8080

docker run -it -d -p 8080:80 -e JWT_ENABLED=false -e USE_UNAUTHORIZED_STORAGE=true -e ONLYOFFICE_HTTPS_HSTS_ENABLED=false --restart=always --name onlyoffice onlyoffice/documentserver
#将配置文件copy出来
docker cp onlyoffice:/etc/onlyoffice/documentserver/default.json ./
#打开修改
nano default.json
"request-filtering-agent" : {
        "allowPrivateIPAddress": true,
        "allowMetaIPAddress": true
},
#复制copy回去
docker cp ./default.json onlyoffice:/etc/onlyoffice/documentserver/default.json
#重启容器
docker restart onlyoffice

2、增加view.html文件

mkdir  /root/onlyoffice
cd /root/onlyoffice
nano view.html

src的值,要填写自己的主机IP,端口号就是刚才创建的onlyoffice容器暴露的端口

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OnlyOffice Viewer</title>
</head>

<body>
<div id="placeholder"></div>
<script type="text/javascript" src="http://主机IP:8080/web-apps/apps/api/documents/api.js"></script>
<script>
function getQueryParamValue(name) {
const searchParams = new URLSearchParams(window.location.search);
return searchParams.get(name);
}

const url = decodeURIComponent(getQueryParamValue("src"));
const fileName = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('?') != -1 ? url.lastIndexOf('?') : url.length);
const fileExtension = fileName.split('.').pop();
const docEditor = new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": fileExtension,
"permissions": {
"edit": false,
"comment": true,
"download": true,
"print": true,
"fillForms": true,
},
"title": fileName,
"url": url,
},
"editorConfig": {
"lang": "zh-CN",
"mode": "view",
},
"height": "1080px",
"type": "desktop",
});
</script>
</body>
</html>

3、安装nginx,修改配置

apt install nginx
nano  /etc/nginx/conf.d/onlyoffice.conf
server {
listen 8081;
server_name localhost;
location / {
   root /root/onlyoffice;  #这里修改为自己的view.html的目录
   index index.html index.htm;
   proxy_redirect off;
   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header Upgrade-Insecure-Requests 1;
   proxy_set_header X-Forwarded-Proto https;
   }
}
systemctl restart nginx 

4、alist预览配置增加

“onlyoffice”:”http://主机IP:8081/view.html?src=$e_url”

暂无评论

发送评论 编辑评论


				
上一篇
下一篇