参考:
https://blog.csdn.net/Aileenvov/article/details/144206206
docker快速安装onlyoffice_docker安装onlyoffice-CSDN博客
修改镜像源
{ "registry-mirrors": [ "https://docker.m.daocloud.io", "https://docker.1panel.live" ] }{ "registry-mirrors": [ "https://docker.m.daocloud.io", "https://docker.1panel.live" ] }{ "registry-mirrors": [ "https://docker.m.daocloud.io", "https://docker.1panel.live" ] }
sudo systemctl restart docker
sudo docker pull onlyoffice/documentserver:7.3
sudo docker run -i -t -d -p 9000:80 -v /home/myOnlyOffice:/var/www/onlyoffice/documentserver/web-apps/wsData --env JWT_SECRET=VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk -e JWT_ENABLED=true onlyoffice/documentserver:7.3sudo docker run -i -t -d -p 9000:80 -v /home/myOnlyOffice:/var/www/onlyoffice/documentserver/web-apps/wsData --env JWT_SECRET=VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk -e JWT_ENABLED=true onlyoffice/documentserver:7.3sudo docker run -i -t -d -p 9000:80 -v /home/myOnlyOffice:/var/www/onlyoffice/documentserver/web-apps/wsData --env JWT_SECRET=VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk -e JWT_ENABLED=true onlyoffice/documentserver:7.3
测试OnlyOffice服务
访问网址:192.168.11.129:9000,需要以IP加端口方式访问,不能用localhost访问。
测试html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- 此处的ip,我onlyoffice所在的机器ip是192.168.7.46,你要改成你自己的服务IP --> <script src="http://192.168.1.50:9000/web-apps/apps/api/documents/api.js"></script> </head> <body style="margin:0px;padding:0px;"> <div id="placeholder" class = "nav" style="width:100%;height:100%;min-height:900px;"></div> </body> <script> new DocsAPI.DocEditor("placeholder", { "document": { "fileType": "pptx", //文件类型,我用的docx文件,你可以根据需要改其他格式等 "key": "13qNAFE", //文件key,确保唯一就行 "title": "今天不加班.pptx", //文件名称 "url": "http://192.168.1.51/map/今天不加班.pptx" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到 }, "documentType": "slide",//文件类型,上面的fileType进行对应匹配 "type": "desktop", "width": "100%", "height": "900px", "editorConfig": { "callbackUrl": "", "lang": "zh-CN" }, "permissions": { "edit": false, "comment": true, "download": true, "fillForms": true, "print": true, "review": true }, "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlZGl0b3JDb25maWciOnsiY2FsbGJhY2tVcmwiOiIiLCJsYW5nIjoiemgtQ04ifSwiZG9jdW1lbnRUeXBlIjoic2xpZGUiLCJwZXJtaXNzaW9ucyI6eyJkb3dubG9hZCI6dHJ1ZSwicHJpbnQiOnRydWUsImVkaXQiOmZhbHNlLCJmaWxsRm9ybXMiOnRydWUsInJldmlldyI6dHJ1ZSwiY29tbWVudCI6dHJ1ZX0sImRvY3VtZW50Ijp7InRpdGxlIjoi5LuK5aSp5LiN5Yqg54-tLnBwdHgiLCJmaWxlVHlwZSI6InBwdHgiLCJrZXkiOiIxM3FOQUZFIiwidXJsIjoiaHR0cDovLzE5Mi4xNjguMS41MS9tYXAv5LuK5aSp5LiN5Yqg54-tLnBwdHgifSwid2lkdGgiOiIxMDAlIiwidHlwZSI6ImRlc2t0b3AiLCJoZWlnaHQiOiI5MDBweCJ9.RBCyWnbHzUj0Bc76b94BGz9HuCrIv0CI9EKlyrqb3eY" }); </script> </html><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- 此处的ip,我onlyoffice所在的机器ip是192.168.7.46,你要改成你自己的服务IP --> <script src="http://192.168.1.50:9000/web-apps/apps/api/documents/api.js"></script> </head> <body style="margin:0px;padding:0px;"> <div id="placeholder" class = "nav" style="width:100%;height:100%;min-height:900px;"></div> </body> <script> new DocsAPI.DocEditor("placeholder", { "document": { "fileType": "pptx", //文件类型,我用的docx文件,你可以根据需要改其他格式等 "key": "13qNAFE", //文件key,确保唯一就行 "title": "今天不加班.pptx", //文件名称 "url": "http://192.168.1.51/map/今天不加班.pptx" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到 }, "documentType": "slide",//文件类型,上面的fileType进行对应匹配 "type": "desktop", "width": "100%", "height": "900px", "editorConfig": { "callbackUrl": "", "lang": "zh-CN" }, "permissions": { "edit": false, "comment": true, "download": true, "fillForms": true, "print": true, "review": true }, "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlZGl0b3JDb25maWciOnsiY2FsbGJhY2tVcmwiOiIiLCJsYW5nIjoiemgtQ04ifSwiZG9jdW1lbnRUeXBlIjoic2xpZGUiLCJwZXJtaXNzaW9ucyI6eyJkb3dubG9hZCI6dHJ1ZSwicHJpbnQiOnRydWUsImVkaXQiOmZhbHNlLCJmaWxsRm9ybXMiOnRydWUsInJldmlldyI6dHJ1ZSwiY29tbWVudCI6dHJ1ZX0sImRvY3VtZW50Ijp7InRpdGxlIjoi5LuK5aSp5LiN5Yqg54-tLnBwdHgiLCJmaWxlVHlwZSI6InBwdHgiLCJrZXkiOiIxM3FOQUZFIiwidXJsIjoiaHR0cDovLzE5Mi4xNjguMS41MS9tYXAv5LuK5aSp5LiN5Yqg54-tLnBwdHgifSwid2lkdGgiOiIxMDAlIiwidHlwZSI6ImRlc2t0b3AiLCJoZWlnaHQiOiI5MDBweCJ9.RBCyWnbHzUj0Bc76b94BGz9HuCrIv0CI9EKlyrqb3eY" }); </script> </html><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- 此处的ip,我onlyoffice所在的机器ip是192.168.7.46,你要改成你自己的服务IP --> <script src="http://192.168.1.50:9000/web-apps/apps/api/documents/api.js"></script> </head> <body style="margin:0px;padding:0px;"> <div id="placeholder" class = "nav" style="width:100%;height:100%;min-height:900px;"></div> </body> <script> new DocsAPI.DocEditor("placeholder", { "document": { "fileType": "pptx", //文件类型,我用的docx文件,你可以根据需要改其他格式等 "key": "13qNAFE", //文件key,确保唯一就行 "title": "今天不加班.pptx", //文件名称 "url": "http://192.168.1.51/map/今天不加班.pptx" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到 }, "documentType": "slide",//文件类型,上面的fileType进行对应匹配 "type": "desktop", "width": "100%", "height": "900px", "editorConfig": { "callbackUrl": "", "lang": "zh-CN" }, "permissions": { "edit": false, "comment": true, "download": true, "fillForms": true, "print": true, "review": true }, "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlZGl0b3JDb25maWciOnsiY2FsbGJhY2tVcmwiOiIiLCJsYW5nIjoiemgtQ04ifSwiZG9jdW1lbnRUeXBlIjoic2xpZGUiLCJwZXJtaXNzaW9ucyI6eyJkb3dubG9hZCI6dHJ1ZSwicHJpbnQiOnRydWUsImVkaXQiOmZhbHNlLCJmaWxsRm9ybXMiOnRydWUsInJldmlldyI6dHJ1ZSwiY29tbWVudCI6dHJ1ZX0sImRvY3VtZW50Ijp7InRpdGxlIjoi5LuK5aSp5LiN5Yqg54-tLnBwdHgiLCJmaWxlVHlwZSI6InBwdHgiLCJrZXkiOiIxM3FOQUZFIiwidXJsIjoiaHR0cDovLzE5Mi4xNjguMS41MS9tYXAv5LuK5aSp5LiN5Yqg54-tLnBwdHgifSwid2lkdGgiOiIxMDAlIiwidHlwZSI6ImRlc2t0b3AiLCJoZWlnaHQiOiI5MDBweCJ9.RBCyWnbHzUj0Bc76b94BGz9HuCrIv0CI9EKlyrqb3eY" }); </script> </html>
生成token:
public static void main(String[] args) throws Exception { JWTSigner signer = JWTSignerUtil.hs256("VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk".getBytes()); Map<String, Object> map = JSONObject.parseObject("{\n" + " \"document\": {\n" + " \"fileType\": \"pptx\", //文件类型,我用的docx文件,你可以根据需要改其他格式等\n" + " \"key\": \"13qNAFE\", //文件key,确保唯一就行\n" + " \"title\": \"今天不加班.pptx\", //文件名称\n" + " \"url\": \"http://192.168.1.51/map/今天不加班.pptx\" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到\n" + " },\n" + " \n" + " \"documentType\": \"slide\",//文件类型,上面的fileType进行对应匹配\n" + " \"type\": \"desktop\",\n" + " \"width\": \"100%\",\n" + " \"height\": \"900px\",\n" + " \"editorConfig\": {\n" + " \"callbackUrl\": \"\",\n" + " \"lang\": \"zh-CN\"\n" + " },\n" + " \"permissions\": {\n" + " \"edit\": false,\n" + " \"comment\": true,\n" + " \"download\": true,\n" + " \"fillForms\": true,\n" + " \"print\": true,\n" + " \"review\": true\n" + " }\n" + " }", Map.class); String token = JWTUtil.createToken(map, signer); System.out.println(token); }public static void main(String[] args) throws Exception { JWTSigner signer = JWTSignerUtil.hs256("VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk".getBytes()); Map<String, Object> map = JSONObject.parseObject("{\n" + " \"document\": {\n" + " \"fileType\": \"pptx\", //文件类型,我用的docx文件,你可以根据需要改其他格式等\n" + " \"key\": \"13qNAFE\", //文件key,确保唯一就行\n" + " \"title\": \"今天不加班.pptx\", //文件名称\n" + " \"url\": \"http://192.168.1.51/map/今天不加班.pptx\" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到\n" + " },\n" + " \n" + " \"documentType\": \"slide\",//文件类型,上面的fileType进行对应匹配\n" + " \"type\": \"desktop\",\n" + " \"width\": \"100%\",\n" + " \"height\": \"900px\",\n" + " \"editorConfig\": {\n" + " \"callbackUrl\": \"\",\n" + " \"lang\": \"zh-CN\"\n" + " },\n" + " \"permissions\": {\n" + " \"edit\": false,\n" + " \"comment\": true,\n" + " \"download\": true,\n" + " \"fillForms\": true,\n" + " \"print\": true,\n" + " \"review\": true\n" + " }\n" + " }", Map.class); String token = JWTUtil.createToken(map, signer); System.out.println(token); }public static void main(String[] args) throws Exception { JWTSigner signer = JWTSignerUtil.hs256("VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk".getBytes()); Map<String, Object> map = JSONObject.parseObject("{\n" + " \"document\": {\n" + " \"fileType\": \"pptx\", //文件类型,我用的docx文件,你可以根据需要改其他格式等\n" + " \"key\": \"13qNAFE\", //文件key,确保唯一就行\n" + " \"title\": \"今天不加班.pptx\", //文件名称\n" + " \"url\": \"http://192.168.1.51/map/今天不加班.pptx\" //文件地址,你可以根据需要改其他地址,前提是本地或外网能够访问的到\n" + " },\n" + " \n" + " \"documentType\": \"slide\",//文件类型,上面的fileType进行对应匹配\n" + " \"type\": \"desktop\",\n" + " \"width\": \"100%\",\n" + " \"height\": \"900px\",\n" + " \"editorConfig\": {\n" + " \"callbackUrl\": \"\",\n" + " \"lang\": \"zh-CN\"\n" + " },\n" + " \"permissions\": {\n" + " \"edit\": false,\n" + " \"comment\": true,\n" + " \"download\": true,\n" + " \"fillForms\": true,\n" + " \"print\": true,\n" + " \"review\": true\n" + " }\n" + " }", Map.class); String token = JWTUtil.createToken(map, signer); System.out.println(token); }
原文链接:https://blog.csdn.net/qq_41050739/article/details/144967692?ops_request_misc=%257B%2522request%255Fid%2522%253A%25225452c8e90db54f7c68f09e672ce81788%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=5452c8e90db54f7c68f09e672ce81788&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-3-144967692-null-null.nonecase&utm_term=%E9%A3%9E%E7%89%9BOS