Try the fastest and simplest way to install ONLYOFFICE

Proxy for Document Server

Integration questions/issues

Proxy for Document Server

Postby Madg » Tue Nov 21, 2017 9:46 am

Hello!

I want to implement Doсument Server in our ERP web system. First target is just viewing of Doc files, no edit.
System bases on micro service architecture, implemented using docker containers
Our files are stored in AWS S3, and also we have 1 stand-alone rest-based micro service for connecting with S3 and caching files
So, i have installed Document Server in single docker container. IP of this container is private and user cant access it from web site, only back-end server can see it.
back-end is made with java, front end is JS.

Objectives:
need to make back-end proxy controller for Document server's requests for 2 reasons:
1) we have own access policy for files each user and files are private objects, each time when user want to see the file we must send first request to server ask database has he permissions or not. then server can give him file or not.
2) we cant share IP of Document Server (in-death requirement) and cant give direct URL of file to JS docEditor object on client side.

So may scheme is looking as :
1) var DocEditor is in JS client side. Each time when user want to see the file he send request to the server, server checks permissions and sends back JSON object for var DocEditor,
2) all links are relative example http://www.mysite/web-apps/doc/..../api.js
3) on back end in controller, i catch all requests with links : "/web-apps/**", "/sdkjs/**", "/doc/**", "/cache/**", "/spellchecker/**", "/fonts/**"
there, i parse these requests and make new request already to Document Server with original request uri, query and body (url in JSON from docEditor JS i replace for "real" url)
for example catch http://mysite.com/web-apps/apps/documen ... rId=iframe]
and make new request as http://ip of document server/web-apps/apps/documenteditor/embed/index.html?_dc=2017-08-11-08-40&lang=en&customer=ONLYOFFICE&frameEditorId=iframe] with body off-course
Also then send response to client with body from response of doc server - in result simple proxy. Also 1 response's body is changed manually - host key in JSON is replaced to relative path.
websockets requests for uri (/spellchecker/**/websocket or /doc/2017211034911511255996349/c/981/5tydbnv4/websocket) - are ignored,

Question:
Can Document Server and DocEditor work without websocket connection? JUST using xhr requests.

And everything is going well but 1 xhr request from client to document server via my proxy is "canceled" and cant be finished, send error back and client can't show the document.
errors from scripts:
sdk-all.js:1817 Uncaught TypeError: Cannot read property 'length' of undefined
at e (sdk-all.js:1817)
at Ea.Yq (sdk-all.js:1836)
at Object.Yq (sdk-all.js:1843)
at Da.Ma.CQb (sdk-all-min.js:540)
at Da.CQb (sdk-all-min.js:730)
at HTMLScriptElement.<anonymous> (sdk-all-min.js:521)

Uncaught TypeError: Cannot read property 'uCa' of null
at Da.Fjb (sdk-all-min.js:616)
at Da.HXa (sdk-all-min.js:710)
at Da.Ma.qTc (sdk-all-min.js:539)
at sdk-all-min.js:721
at Ga (sdk-all-min.js:305)
at success (sdk-all-min.js:306)
at XMLHttpRequest.Ma.onreadystatechange (sdk-all-min.js:274)

this request sends again in cycle form client
/doc/2017211034911511255996349/c/981/pkssglqo/xhr?t=1511256230883
this request is "canceled" and cant be finished,
/spellchecker/doc/201721107811511256662078/c/763/tlj5yjrc/xhr?t=1511256664587
In result editor is shown in browser with out file.

Maybe there is any default solution how to make working proxy for document server?

Thanks for help.
Madg
 
Posts: 3
Joined: Tue Nov 14, 2017 8:34 am

Re: Proxy for Document Server

Postby Madg » Tue Nov 21, 2017 12:22 pm

maybe problem in that i don't reply all headers from response of document server to client in my java proxy?
Is any need info transferred via headers from doc server to client? or info only in body of response?
Is any way to turn off spell checker?
I checked https://helpcenter.onlyoffice.com/serve ... proxy.aspx about X-Forwarded-Proto and X-Forwarded-Host headers, but it is not clear where i have add it in my java controller.
Madg
 
Posts: 3
Joined: Tue Nov 14, 2017 8:34 am

Re: Proxy for Document Server

Postby Madg » Thu Nov 23, 2017 6:36 am

The problem was solved, just added needed X-Forward-Proto and -Host to request from proxy controller to real document server and a little bit specify types of body responses to client according to content-type from document server.
Madg
 
Posts: 3
Joined: Tue Nov 14, 2017 8:34 am

Re: Proxy for Document Server

Postby Maxim » Mon Nov 27, 2017 2:19 pm

Hello Madg!
Great that you have solved it!
Anyway there are some examples of document-server-proxy configs
Maxim
 
Posts: 1237
Joined: Tue Oct 11, 2016 2:34 pm


Return to API

Who is online

Users browsing this forum: No registered users and 1 guest