Reverse proxy url with https protocol passed as argument in builder script does not open file for processing

I am running document server in a network of docker containers. I have configured Traefik as reverse proxy and set up routing to different services. I am calling document builder api from a backend server running in another container. The problem I am currently facing is that I get response with error -3. The file opening does not seem to work. Here is the payload.

{'url': 'https://proxy/ds/form_submission.docbuilder', 'async': False, 'key': 'fYYY88iixhaiU', 'argument': {'doc_url': 'https://proxy/api/docs/ttYYvyy66yYYgggDD/download/', 'filename': 'filled_form.pdf', 'data': [{'key': 'company_name', 'value': 'Random name'}]}}

and the script looks like below

var sDocURL = Argument["doc_url"];
var sDocName = Argument["filename"];
var sFormsData = Argument["data"]
builder.OpenFile("jsValue(sDocURL)");
var oDocument = Api.GetDocument();
oDocument.SetFormsData(Argument["data"]);
builder.SaveFile("pdf", "jsValue(sDocName)");
builder.CloseFile();

If I use docker internal network and send the following as payload, it succeeds. The difference is that I am using http://backend:8000/api/docs/ttYYvyy66yYYgggDD/download/ as value for doc_url argument

{'url': 'https://proxy/ds/form_submission.docbuilder', 'async': False, 'key': 'fYYY88iixhaiU', 'argument': {'doc_url': 'http://backend:8000/api/docs/ttYYvyy66yYYgggDD/download/', 'filename': 'filled_form.pdf', 'data': [{'key': 'company_name', 'value': 'Random name'}]}}

Although it succeeds, no token is attached to headers when the file download request is made by onlyoffice server. The onlyoffice server url I am using is https://proxy/docbuilder. I am using version 8.2

Hello @anup

Have you tried accessing URL to file (doc_url) from the container with Document Server directly with, for instance, wget?

Yes, I tried that and it works.

So, if the file is accessible from the container, then Document Server should be able to pick it up. Do you receive any error in the process, besides -3?
By the way, -3 states for document generation error, about which you can find more information in logs of Document Server. See all error codes here:
https://api.onlyoffice.com/docs/docs-api/additional-api/document-builder-api/#possible-error-codes-and-their-description

The onlyoffice server logs in the container contains Api not defined error when I use https. The error in the backend server logs does not log any error besides -3.

Also, other problem is that when I use http protocol and docker network internal communication, I do not receive token in the request headers. I am using https protocol and reverse proxy url for loading editor in the frontend as well, which works fine and the download request from the editor does attach token to request headers.

You should take a look at the samples that we provide for most popular proxy usages:

Please reference the one that fits your scenario and make necessary changes if needed.

Thanks for your reply. I would like to confirm from you that if every request that originates from onlyoffice document server when opening a file from a builder script does contain token attached to the request headers.

I’m not following your question - what kind of token you are talking about? As far as I know, Document Server simply utilized GET request to download the file via provided link.

I mean when I use the configuration for the loading onlyoffice editor in the frontend, the editor sends a request to the url specified in the cofiguration for uploading the document. This request contain authentication token in headers which I am using first to authenticate the request and send the document as response.

But, when I am using docbuilder api to open the document and fill form data, the request to fetch the document does not have token attached to headers and need to bypass the authentication. I want that the GET request from the document server to have jwt token attached to headers so that I can authenticate it in this case too.

According to this documentation Token in header , every outgoing request from documentserver should contain jwt token in header. But, I am not getting token attached to the GET request headers when using document builder api with above script while opening the file.

I also tried with converter api Conversion API and I do get jwt token in headers for outgoing GET request from documentserver to fetch the file for conversion.

I don’t get token in headers only when using document builder api and the script which opens a file

What is version of Document Server that you are using?

Also, may I ask you to run a test? It is quite simple:

  1. Prepare a separate .docbuilder script for test;
  2. Use exact values for it instead of arguments, i.e. do not pass any arguments to the script;
  3. Send it in the signed request to the Web Document Builder service;
  4. Check if the token persists in the header in this scenario.

I am looking forward to your feedback.

Hi!

I am using developer edition 8.2 onlyoffice/documentserver-de:8.2 image . I tried with hardcoding values in the script. Still, the token is not persisting.

Our company is testing onlyoffice as a tool to create document automation. We are generating templates from documents in onlyoffice editor and we want to create documents dynamically in our backend. This is very much a required feature. We also need that every request coming from documentserver to our backend to have token attached to its headers.

We run some additional checks on this situation. Please await for my feedback.

@Constantine Do you have any updates on this ?

We are still working on it.

@Constantine Is this a problem in onlyoffice api ?

There are no results available as we keep on checking out the situation, hence I cannot answer that question yet.

Just got an update: we’ve registered a bug on the current situation for further investigation. I will keep you posted about the updates.