Onlyoffice - Document could not be saved

Hi

I have upgraded today to version 6.1 pro and made the integration with Onlyoffice document server.
The integration basically works but when the document opens I receive the message

“The document could not be saved. Please check connection …”

I have done the whole setup with SSL. The document server runs with a subdomain and assigned certificate.

Here is my nginx configuration

# Required for only office document server
map $http_host $this_host {
    "" $host;
    default $http_host;
}

map $http_x_forwarded_proto $the_scheme {
        default $http_x_forwarded_proto;
        "" $scheme;
    }

map $http_x_forwarded_host $the_host {
        default $http_x_forwarded_host;
        "" $this_host;
    }

map $http_upgrade $proxy_connection {
        default upgrade;
        "" close;
    }

#
# Force HTTP Redirect
#
server {
    listen [::]:80 ;
    listen 80 ;
    server_name office.domain.com;
    server_name_in_redirect off;
    rewrite ^ https://$http_host$request_uri permanent; # enforce https redirect
}
#
# Force HTTP Redirect
#
server {
    listen [::]:80 ;
    listen 80 ;
    server_name office.domain.com;
    server_name_in_redirect off;
    rewrite ^ https://$http_host$request_uri permanent; # enforce https redirect
}


server {
    listen [::]:443 ssl ;
    listen 443 ssl ;
    server_name office.domain.com;

    access_log /var/log/nginx/office.domain.com-access_log;
    error_log /var/log/nginx/office.domain.com-error_log;
    error_page 403 404 500 502 503 504 /error/error.html;

    # enable ssl
    ssl on;
    ssl_certificate /etc/letsencrypt/live/my.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my.domain.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_ciphers "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!AES256";
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/ssl/dhp-2048.pem;

    location / {
        proxy_pass http://127.0.0.1:9980;
        proxy_http_version 1.1;
        client_max_body_size 100; # Limit Document size to 100MB
        proxy_read_timeout 3600s;
        proxy_connect_timeout 3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $proxy_connection;

        # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
        proxy_set_header X-Forwarded-Host $the_host;

        proxy_set_header X-Forwarded-Proto $the_scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }
}

Testing the document server via https://office.domain.com/welcome all works fine

Here is my conf/seahub_settings.py

# Enable Only Office
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = True
ONLYOFFICE_APIJS_URL = 'https://office.domain.com/web-apps/apps/api/documents/api.js'
ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')

What I saw is that I am getting an error in the onlxoffice log file documentserver/docservice/out.log

[2017-06-20 10:54:44.360] [ERROR] nodeJS - postData error: docId = dcba37c2340c349efdc1;url = http://cloud.domain.com/onlyoffice/editor-callback/;data = {"key":"dcba37c2340c349efdc1","status":1,"users":["uid-1497956080805"],"actions":[{"type":1,"userid":"uid-1497956080805"}]}
Error: Error response: statusCode:301 ;body:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.2</center>
</body>
</html>

    at Request._callback (/var/www/onlyoffice/documentserver/server/Common/sources/utils.js:260:18)
    at Request.self.callback (/var/www/onlyoffice/documentserver/server/Common/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/var/www/onlyoffice/documentserver/server/Common/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/var/www/onlyoffice/documentserver/server/Common/node_modules/request/request.js:1091:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)

The return URL http://cloud.domain.com is without HTTPS… but in the seafile configuration like SERVICE_URL i use https…
Further I redirect http to https on cloud.domain.com

Is this creating the error? where to change the return URL?

Please let me know

Thank you

Gino

Are you able to call the document server page from external? You should be redirected to a /welcome/ page.

Hi Danilo
Yes, is working well, no problem there… the document is also opening but it appears the error message as mentioned and then I can change the document but I cannot save it anymore… I guess it has something to do with the return URL… not sure…
therefore I want to test to put the return URL to https… but I cannot find the place where it has to be changed… from http://cloud.domain.com to https://cloud.domain.com

Your nginx config and then the seahub config has to be adjusted.

I have done my tutorial over and over again, even by just copy pasting, It always works. Tried it on Debian Jessie only though. But it should be the same on Ubuntu and CentOS. :slight_smile:

I cannot find any wrong setup in my config…
Can you please explain what has to be changed?
Thanks

I don’t know what has to be changed and if anything has to be changed.

I sugest you to go through every step carefully again and check at every step if this step was successfull.

Well, this statement does not help me at all…

Anybody else who can answer to my question about the Return URL…

Thank you!

After some testing I saw that for some documents is working without problems… maybe it depends on the file content?

But now I know that the result URL without https works!

I wrote the guide, I am no developer though. :wink:

It may depend on the content, but saving should still work.

I feel like the reverse proxy configuration issue of the seafile.
When you open a doc, look at the page source code.

var config = {
“document”: {
“fileType”: “docx”,
“key”: “d70457b490580adb95c5”,
“title”: “t1.docx”,
“url”: “https://xxx.xxx.xxx/seafhttp/files/2cd876a3-1aa9-4422-97db-e77379d9d991/t1.docx”,
“permissions”: {
“download”: true,
“edit”: true,
“print”: true,
“review”: true
},
},
“documentType”: “text”, // ‘text’ | ‘spreadsheet’ | ‘presentation’,
“editorConfig”: {
“callbackUrl”: “https://xxx.xxx.xxx/onlyoffice/editor-callback/”,
“lang”: “en”,
“mode”: “edit”,
“user”: {
“name”: “Teng”
}
},
};
If it is http instead of https, then your reverse proxy has some issue.
Do you configure your seafile to use https as well? I mean https for not only the front-end proxy, but also the back-end part.

Hi

No, there is all ok, both links are https. As told in previous mail I do not have the issue with all files.
For example I have the problem with the document “seafile-tutorial.doc”. This file will open but I am getting message “The document could not be saved…”

did not found a logic until now when it works and when not… I have to take this under observation…

Hi again
I think I have found the reason… it is due to the “-” in the file name… when I remove the “-” in the file name “seafile-tutorial.doc” it works… :confused:

Is this still a seafile problem or is there a way to fix this problem related with spaces and special char?

Thank you

That’s strange. It does remind me an old bug that a file link will become 404 if the file name contains the space character. Later, it turns out to be the issue of apache reverse proxy. Here is the link if interested https://github.com/haiwen/seafile/issues/1258#issuecomment-188866740

So my guess is still probably the proxy server configuration issue or nginx bug. I am using the apache as the reverse proxy server. So far I have tried opening the seafile-tutorial.doc with onlyoffice and don’t observe such an issue.

Hi
This is strange… i tried with different types of special character like ?!%… and works well with all, also space is not a problem… only make problems with “-” in the filename… but the strangest is that the error happens not every time… I have to take this under observation… in the moment I do not see any logic in this error…

Did you find a solution? If not, did you install the document server via docker?

Hi…
No, no solution yet
Yes, onlyoffice is installed via docker and accessed via subdomain with nginx reverse proxy

//edit: Sorry, at first I didn’t read, that you use the Pro version, as I don’t know if my vhost works for Pro, too. Maybe this helps anyone else. :slight_smile:

Okay. I have the same configuration and for me everything works fine. But I have a different nginx vhost. Maybe worth a try?

server {
    listen       80;
    server_name  doc.domain.com;
    return 301 https://$host$request_uri;
}

server {
listen 443;
server_name doc.domain.com;

####

ssl on;
ssl_protocols TLSv1.2;
ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ecdh_curve secp384r1;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_certificate /etc/letsencrypt/live/domain.com-0002/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com-0002/privkey.pem;
ssl_stapling on;
ssl_stapling_verify on;

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header X-Content-Type-Options nosniff;

gzip off;

server_tokens off;

 location / {
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass              http://localhost:8083/;
 }
}

You need to adjust your docker port at proxy_pass. (I started via
sudo docker run -i -t -d -p 8083:80 onlyoffice/documentserver)

Hi
Thank you for your suggestion, but it is the same situation.

Now I think I found now the reason … i is a onlyoffice cache problem I guess… when a document had an error when opening, this error happens again and again… I did not found quickly how to delete the cache in onlyoffice, so I reinstalled the docker container and now it works also with the files which previously doesn’t
So I guess there initially was a configuration problem, I tried to open some file, and afterwards onlyoffice
retried to open the file in cache… or something like this…

Not really clear what happened, but now is working… :slight_smile:

You can restart the docker image every night to have it clear the cache.
Don’t set a specific cache directory though.

I got same problem that Onlyoffice changes are not saved back to Seafile, and solve it via enabling "forcesave": true mode in Onlyoffice editor config, so I add into conf/seahub_settings.py this line:

ONLYOFFICE_FORCE_SAVE = True

and after restarting seahub - Onlyoffice shows “Save” button, that works well and save all changes into Seafile library!