OnlyOffice

From version 6.1.0+ on (including CE), Seafile supports OnlyOffice to view/edit office files online. In order to use OnlyOffice, you must first deploy an OnlyOffice server.

Info for clusters

In a cluster setup we recommend a dedicated DocumentServer host or a DocumentServer Cluster on a different subdomain.
Technically it works also via subfolder if the loadbalancer can handle folder for loadbalancing.

For most users we recommend to deploy the documentserver in a docker image locally and provide it via a subfolder.

Benefits:

  • no additional server required
  • no additional subdomain required
  • no additional SSL certificate required
  • easy and quick deployment
  • easy management

Summary

Deployment of DocumentServer via SUBDOMAIN

URL example: https://onlyoffice.domain.com

  • Subdomain
  • DNS record for subdomain
  • SSL certificate (LE works also)

For a quick and easy installation, we suggest you use ONLYOFFICE/Docker-DocumentServer for a subdomain installation. Just follow the guide in the OnlyOffice documentation.

Test that DocumentServer is running via SUBDOMAIN

After the installation process is finished, visit this page to make sure you have deployed OnlyOffice successfully: http{s}://{your Seafile Server's domain or IP}/welcome, you will get Document Server is running info at this page.

Configure Seafile Server for SUBDOMAIN

Add the following config option to seahub_settings.py.

  1. # Enable Only Office
  2. ENABLE_ONLYOFFICE = True
  3. VERIFY_ONLYOFFICE_CERTIFICATE = False
  4. ONLYOFFICE_APIJS_URL = 'http{s}://{your OnlyOffice server's domain or IP}/web-apps/apps/api/documents/api.js'
  5. ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')
  6. ONLYOFFICE_EDIT_FILE_EXTENSION = ('docx', 'pptx', 'xlsx')

Then restart the Seafile Server

  1. ./seafile.sh restart
  2. ./seahub.sh restart
  3. # or
  4. service seafile-server restart

When you click on a document you should see the new preview page.

Deployment of DocumentServer via SUBFOLDER

URL example: https://seafile.domain.com/onlyofficeds

  • Local proxy to subfolder on already existing Seafile Server (sub)domain.
  • SSL via Seafile Server domain, no additional certificate required !

Do NOT CHANGE the SUBFOLDER if not absolutely required for some reason!

The subfolder page is only important for communication between Seafile and the DocumentServer, there is nothing except the welcome page (e.g. no overview or settings). Users will need access to it though for the OnlyOffice document server editor to work properly.

/onlyoffice/ cannot be used as subfolder as this path is used for communication between Seafile and Document Server !

The following guide shows how to deploy the OnlyOffice Document server locally.
It is based on the “ONLYOFFICE/Docker-DocumentServer” documentation.

Requirements for OnlyOffice DocumentServer via Docker
https://github.com/ONLYOFFICE/Docker-DocumentServer#recommended-system-requirements

Install Docker

Ubuntu, Debian, CentOS

Deploy OnlyOffice DocumentServer Docker image

This downloads and deploys the DocumentServer on the local port 88.

Debian 8

  1. docker run -i -t -d -p 88:80 --restart=always --name oods onlyoffice/documentserver

Ubuntu 16.04

  1. docker run -dit -p 88:80 --restart always --name oods onlyoffice/documentserver

Nothing yet confirmed on CentOS 7, you may try any of the above commands, they may work also.

EXAMPLE: Debian Docker container with MEMORY LIMITS

In Debian 8 you first have to change some settings in the grub config to support memory limits for docker.

  1. # Edit /etc/default/grub
  2. # Add the following options
  3. GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"
  4. # Update Grub2 and reboot
  5. update-grub2 && reboot

Now you can start the docker image with memory limits.
docker run -i -t -d -p 88:80 --restart=always --memory "6g" --memory-swap="6g" --name oods onlyoffice/documentserver

These limits are above the minimum recommendation (4G RAM/2GB SWAP) so the DocumentServer’s performance keeps up, while multiple users edit documents. Docker SWAP works different from machine SWAP, check the docker documentation.

Docker documentation

If you have any issues please check the docker documentation.

Auto-starting the docker image.

If you wish to limit the resources that docker uses check the docker documentation.

Configure Webserver

Configure Nginx

Variable mapping

Add the following configuration to your seafile nginx .conf file (e.g. /etc/ngnix/conf.d/seafile.conf) out of the server directive. These variables are to be defined for the DocumentServer to work in a subfolder.

  1. # Required for only office document server
  2. map $http_x_forwarded_proto $the_scheme {
  3. default $http_x_forwarded_proto;
  4. "" $scheme;
  5. }
  6. map $http_x_forwarded_host $the_host {
  7. default $http_x_forwarded_host;
  8. "" $host;
  9. }
  10. map $http_upgrade $proxy_connection {
  11. default upgrade;
  12. "" close;
  13. }

Proxy server settings subfolder

Add the following configuration to your seafile nginx .conf file (e.g. /etc/ngnix/conf.d/seafile.conf) within the server directive.

  1. ...
  2. location /onlyofficeds/ {
  3. # THIS ONE IS IMPORTANT ! - Trailing slash !
  4. proxy_pass http://{your Seafile server's domain or IP}:88/;
  5. proxy_http_version 1.1;
  6. client_max_body_size 100M; # Limit Document size to 100MB
  7. proxy_read_timeout 3600s;
  8. proxy_connect_timeout 3600s;
  9. proxy_set_header Upgrade $http_upgrade;
  10. proxy_set_header Connection $proxy_connection;
  11. # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
  12. proxy_set_header X-Forwarded-Host $the_host/onlyofficeds;
  13. proxy_set_header X-Forwarded-Proto $the_scheme;
  14. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  15. }
  16. ...

Configure Apache

BETA - Requires further testing!

Add the following configuration to your seafile apache config file (e.g. sites-enabled/seafile.conf) outside the <VirtualHost > directive.

  1. ...
  2. LoadModule authn_core_module modules/mod_authn_core.so
  3. LoadModule authz_core_module modules/mod_authz_core.so
  4. LoadModule unixd_module modules/mod_unixd.so
  5. LoadModule proxy_module modules/mod_proxy.so
  6. LoadModule proxy_http_module modules/mod_proxy_http.so
  7. LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
  8. LoadModule headers_module modules/mod_headers.so
  9. LoadModule setenvif_module modules/mod_setenvif.so
  10. <IfModule unixd_module>
  11. User daemon
  12. Group daemon
  13. </IfModule>
  14. ...

Add the following configuration to your seafile apache config file (e.g. sites-enabled/seafile.conf) inside the <VirtualHost > directive at the end.

  1. ...
  2. Define VPATH /onlyofficeds
  3. Define DS_ADDRESS {your Seafile server's domain or IP}:88
  4. ...
  5. <Location ${VPATH}>
  6. Require all granted
  7. SetEnvIf Host "^(.*)$" THE_HOST=$1
  8. RequestHeader setifempty X-Forwarded-Proto http
  9. RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
  10. RequestHeader edit X-Forwarded-Host (.*) $1${VPATH}
  11. ProxyAddHeaders Off
  12. ProxyPass "http://${DS_ADDRESS}/"
  13. ProxyPassReverse "http://${DS_ADDRESS}/"
  14. </Location>
  15. ...

Test that DocumentServer is running via SUBFOLDER

After the installation process is finished, visit this page to make sure you have deployed OnlyOffice successfully: http{s}://{your Seafile Server's domain or IP}/{your subdolder}/welcome, you will get Document Server is running info at this page.

Configure Seafile Server for SUBFOLDER

Add the following config option to seahub_settings.py:

  1. # Enable Only Office
  2. ENABLE_ONLYOFFICE = True
  3. VERIFY_ONLYOFFICE_CERTIFICATE = True
  4. ONLYOFFICE_APIJS_URL = 'http{s}://{your Seafile server's domain or IP}/{your subdolder}/web-apps/apps/api/documents/api.js'
  5. ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')
  6. ONLYOFFICE_EDIT_FILE_EXTENSION = ('docx', 'pptx', 'xlsx')

Then restart the Seafile Server

  1. ./seafile.sh restart
  2. ./seahub.sh restart
  3. # or
  4. service seafile-server restart

When you click on a document you should see the new preview page.

Complete Nginx config EXAMPLE

Complete nginx config file (e.g. /etc/nginx/conf.d/seafile.conf) based on Seafile Server V6.1 including OnlyOffice DocumentServer via subfolder.

  1. # Required for OnlyOffice DocumentServer
  2. map $http_x_forwarded_proto $the_scheme {
  3. default $http_x_forwarded_proto;
  4. "" $scheme;
  5. }
  6. map $http_x_forwarded_host $the_host {
  7. default $http_x_forwarded_host;
  8. "" $host;
  9. }
  10. map $http_upgrade $proxy_connection {
  11. default upgrade;
  12. "" close;
  13. }
  14. server {
  15. listen 80;
  16. server_name seafile.domain.com;
  17. rewrite ^ https://$http_host$request_uri? permanent; # force redirect http to https
  18. server_tokens off;
  19. }
  20. server {
  21. listen 443 http2;
  22. ssl on;
  23. ssl_certificate /etc/ssl/cacert.pem; # path to your cacert.pem
  24. ssl_certificate_key /etc/ssl/privkey.pem; # path to your privkey.pem
  25. server_name seafile.domain.com;
  26. proxy_set_header X-Forwarded-For $remote_addr;
  27. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  28. server_tokens off;
  29. #
  30. # seahub
  31. #
  32. location / {
  33. fastcgi_pass 127.0.0.1:8000;
  34. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  35. fastcgi_param PATH_INFO $fastcgi_script_name;
  36. fastcgi_param SERVER_PROTOCOL $server_protocol;
  37. fastcgi_param QUERY_STRING $query_string;
  38. fastcgi_param REQUEST_METHOD $request_method;
  39. fastcgi_param CONTENT_TYPE $content_type;
  40. fastcgi_param CONTENT_LENGTH $content_length;
  41. fastcgi_param SERVER_ADDR $server_addr;
  42. fastcgi_param SERVER_PORT $server_port;
  43. fastcgi_param SERVER_NAME $server_name;
  44. fastcgi_param REMOTE_ADDR $remote_addr;
  45. fastcgi_param HTTPS on;
  46. fastcgi_param HTTP_SCHEME https;
  47. access_log /var/log/nginx/seahub.access.log;
  48. error_log /var/log/nginx/seahub.error.log;
  49. fastcgi_read_timeout 36000;
  50. client_max_body_size 0;
  51. }
  52. #
  53. # seafile
  54. #
  55. location /seafhttp {
  56. rewrite ^/seafhttp(.*)$ $1 break;
  57. proxy_pass http://127.0.0.1:8082;
  58. client_max_body_size 0;
  59. proxy_connect_timeout 36000s;
  60. proxy_read_timeout 36000s;
  61. proxy_send_timeout 36000s;
  62. send_timeout 36000s;
  63. }
  64. location /media {
  65. root /home/user/haiwen/seafile-server-latest/seahub;
  66. }
  67. #
  68. # seafdav (webdav)
  69. #
  70. location /seafdav {
  71. fastcgi_pass 127.0.0.1:8080;
  72. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  73. fastcgi_param PATH_INFO $fastcgi_script_name;
  74. fastcgi_param SERVER_PROTOCOL $server_protocol;
  75. fastcgi_param QUERY_STRING $query_string;
  76. fastcgi_param REQUEST_METHOD $request_method;
  77. fastcgi_param CONTENT_TYPE $content_type;
  78. fastcgi_param CONTENT_LENGTH $content_length;
  79. fastcgi_param SERVER_ADDR $server_addr;
  80. fastcgi_param SERVER_PORT $server_port;
  81. fastcgi_param SERVER_NAME $server_name;
  82. fastcgi_param HTTPS on;
  83. client_max_body_size 0;
  84. access_log /var/log/nginx/seafdav.access.log;
  85. error_log /var/log/nginx/seafdav.error.log;
  86. }
  87. #
  88. # onlyofficeds
  89. #
  90. location /onlyofficeds/ {
  91. # IMPORTANT ! - Trailing slash !
  92. proxy_pass http://127.0.0.1:88/;
  93. proxy_http_version 1.1;
  94. client_max_body_size 100M; # Limit Document size to 100MB
  95. proxy_read_timeout 3600s;
  96. proxy_connect_timeout 3600s;
  97. proxy_set_header Upgrade $http_upgrade;
  98. proxy_set_header Connection $proxy_connection;
  99. # IMPORTANT ! - Subfolder and NO trailing slash !
  100. proxy_set_header X-Forwarded-Host $the_host/onlyofficeds;
  101. proxy_set_header X-Forwarded-Proto $the_scheme;
  102. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  103. }
  104. }

Complete Apache config EXAMPLE

BETA - Requires further testing!

  1. LoadModule authn_core_module modules/mod_authn_core.so
  2. LoadModule authz_core_module modules/mod_authz_core.so
  3. LoadModule unixd_module modules/mod_unixd.so
  4. LoadModule proxy_module modules/mod_proxy.so
  5. LoadModule proxy_http_module modules/mod_proxy_http.so
  6. LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
  7. LoadModule headers_module modules/mod_headers.so
  8. LoadModule setenvif_module modules/mod_setenvif.so
  9. LoadModule ssl_module modules/mod_ssl.so
  10. <IfModule unixd_module>
  11. User daemon
  12. Group daemon
  13. </IfModule>
  14. <VirtualHost *:80>
  15. ServerName seafile.domain.com
  16. ServerAlias domain.com
  17. Redirect permanent / https://seafile.domain.com
  18. </VirtualHost>
  19. <VirtualHost *:443>
  20. ServerName seafile.domain.com
  21. DocumentRoot /var/www
  22. SSLEngine On
  23. SSLCertificateFile /etc/ssl/cacert.pem
  24. SSLCertificateKeyFile /etc/ssl/privkey.pem
  25. ## Strong SSL Security
  26. ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_Apache2.html
  27. SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
  28. SSLProtocol All -SSLv2 -SSLv3
  29. SSLCompression off
  30. SSLHonorCipherOrder on
  31. Alias /media /home/user/haiwen/seafile-server-latest/seahub/media
  32. <Location /media>
  33. Require all granted
  34. </Location>
  35. RewriteEngine On
  36. #
  37. # seafile fileserver
  38. #
  39. ProxyPass /seafhttp http://127.0.0.1:8082
  40. ProxyPassReverse /seafhttp http://127.0.0.1:8082
  41. RewriteRule ^/seafhttp - [QSA,L]
  42. #
  43. # seahub
  44. #
  45. SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
  46. SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  47. ProxyPass / fcgi://127.0.0.1:8000/
  48. #
  49. # onlyofficeds
  50. #
  51. Define VPATH /onlyofficeds
  52. Define DS_ADDRESS {your Seafile server's domain or IP}:88
  53. <Location ${VPATH}>
  54. Require all granted
  55. SetEnvIf Host "^(.*)$" THE_HOST=$1
  56. RequestHeader setifempty X-Forwarded-Proto http
  57. RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
  58. RequestHeader edit X-Forwarded-Host (.*) $1${VPATH}
  59. ProxyAddHeaders Off
  60. ProxyPass "http://${DS_ADDRESS}/"
  61. ProxyPassReverse "http://${DS_ADDRESS}/"
  62. </Location>
  63. </VirtualHost>