Hi everyone!
I’m super new to Onlyoffice I’m creating this post in order to get some help/feedback/guidance on a possible future project.
Right now I’m trying to create a proof-of-concept to demonstrate the capability of Onlyoffice to view a simple docx document in a simple HTML page. The goal in the future would be to integrate Onlyoffice in a specific app for my company.
Onlyoffice will be running on docker.
My configurations are as following:
- I running docker with the following settings:
docker run -i -t -d -p 80:80 --restart=always -v /home/Dev/onlyoffice-docker/onlyoffice_docx_volume:/var/lib/onlyoffice/documentserver-example/files -e JWT_ENABLED=false onlyoffice/documentserver-de
Since this is for test propose only i’m disabling JWT.
Accordingly, and after some searching, I’m also enabling the "allowPrivateIPAddress": true
option in /etc/onlyoffice/documentserver/default.json
since I was having error when trying to create or upload a docx file in the “example mode”.
With this I can use the example (http://127.0.0.1/example/
) just fine.
- Now I want to use the API to display a docx document in a simple HTML page. I tried to follow the documentation as best as i could and I come up with the following HTML page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OnlyOffice Document Editor</title>
</head>
<body>
<div id="editor-container" style="width: 100%; height: 600px;"></div>
<script type="text/javascript" src="http://localhost/web-apps/apps/api/documents/api.js"></script>
<script>
window.onload = function() {
new DocsAPI.DocEditor('editor-container', {
documentType: 'word',
document: {
url: 'http://172.17.0.2/test.docx',
fileType: 'docx'
}
});
};
</script>
</body>
</html>
No matter what URL i use in the url
field I’m always getting the following error:
[2024-05-16T14:43:48.570] [ERROR] [localhost] [a2aab94aee10227fa681] [uid-1715790232804] nodeJS - error downloadFile:url=http://172.17.0.2/test.docx;attempt=3;code:null;connect:null Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Thu, 16 May 2024 14:43:48 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-encoding":"gzip"};
Where: 172.17.0.2
is the docker container IP
My questions are:
Should I use a specific folder to “serve” the document?
I’ve tried to serve the document from my local disc (outside the docker container) but with this I always got an Invalid URI
error as follow:
[2024-05-16T15:22:13.160] [ERROR] [localhost] [a131b6352abb1d305919] [uid-1715790232804] nodeJS - error downloadFile:url=/home/jsilva/Dev/onlyoffice-docker/test.docx;attempt=3;code:null;connect:null Error: Invalid URI "/home/Dev/onlyoffice-docker/test.docx"
The same happens if I specify some directory inside the docker container as well:
[2024-05-16T15:24:35.500] [ERROR] [localhost] [f39b906d4edf6a5f4128] [uid-1715790232804] nodeJS - error downloadFile:url=/var/lib/onlyoffice/documentserver-example/files/test.docx;attempt=3;code:null;connect:null Error: Invalid URI "/var/lib/onlyoffice/documentserver-example/files/test.docx"
What am I missing?
I’ve been digging the internet for the last couple of days but I still didn’t find anything that would help me to move forward. Any feedback or guidance would be deeply appreciated!
Thanks in advance!