Onlyoffice docker with a simple HTML page

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:

  1. 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.

  1. 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!

Hello.
In case you want to integrate Document Server with your own application, you need to provide all the needed parameters in the Editor’s initialization config, including unique document identifier (key, url, and other parameters)
Here is the documentation how the opening of documents should be implemented by you: ONLYOFFICE Api Documentation - Opening File
Here is how you should configure the saving: ONLYOFFICE Api Documentation - Saving File
What matters is that the document should be available for downloading by Document Server by url, there is no specified folder where the document should be stored. The url to the document should be provided in document.url parameter of the config.

You can see an example of the integration by documentserver_url/example address. But first you need to launch it by running the command provided on documentserver_url/welcome page.

Pay attention to the fact that you installed commercial Developer Edition version, if you have a license, you can send us questions via Zendesk.

Hi @DmitriiV,

Thank you so much for your feedback, these are awesome pointers for my next steps! I deeply appreciate it!

As for now, I’m only testing the possibility of the integration of onlyoffice within our application (and entce my current testing) and If everything goes as planned the goal would be to purchase a commercial license when we decide to move forward.

Regarding my initial question, for anyone who may come across with the same issue, I managed to fix it by adding a new location block to serve files from the DocumentServerData directory in nginx file /etc/onlyoffice/documentserver/nginx/includes/ds-docservice.conf :

location /DocumentServerData/ {
     alias /var/www/onlyoffice/DocumentServerData/;
     autoindex on;
}

All the best!