Skip to content
onlyoffice部署

onlyoffice部署

onlyoffice

DANGER

该教程由 官方 提供 如果繁琐看不懂 可看 @小火柴阿教程

OnlyOffice配置教程

1.字段说明

密钥:安装OnlyOffice时候的密钥,这个只有7.2及以上支持,未设置密钥或者无密钥的低版本留空即可

文档外网:OnlyOffice的外网地址,主要用于浏览器加载OnlyOffice的模块,保证浏览器能访问到OnlyOffice即可

文档内网:OnlyOffice的内网地址,主要用于Webos向OnlyOffice交互使用的,保证webos程序代码能够访问到OnlyOffice即可

系统内网:Webos的内网地址,主要用于OnlyOffice向Webos交互使用的,保证OnlyOffice程序代码能够访问到Webos即可

注意: 如果webos采用docker安装,则文档内网不能是localhost或者127.0.0.1;如果onlyoffice采用docker安装,则系统内网不能是localhost或者127.0.0.1;因为docker是虚拟机,对于代码而言,localhost或者127.0.0.1是指向本机,也就是docker容器内部了,无法指向宿主机,如果webos浏览器地址携带了https,则文档外网也必须携带,这个受限于浏览器的规则,https的网站只能加载https的资源,请使用nginx或者宝塔通过代理给onlyoffice加SSL后再试

点我查看官网https配置教程

上面教程看不懂?没关系,下面是nginx的具体配置,复制即可使用

upstream docservice {
  server 127.0.0.1:8001;
}
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;
}

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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;

## Normal HTTP host
server {
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_name _;
  server_tokens off;

  ## Redirects all traffic to the HTTPS host
  return 301 https://$server_name:443$request_uri;
}


server
{
    listen 80;
		listen 443 ssl http2;
    server_name onlyoffice.tenfell.cn;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/onlyoffice.tenfell.cn;

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/xxx/fullchain.pem;
    ssl_certificate_key    /www/xxx/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header X-Content-Type-Options nosniff;
    location / {
      proxy_pass http://docservice;
      proxy_http_version 1.1;
    }
}
upstream docservice {
  server 127.0.0.1:8001;
}
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;
}

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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;

## Normal HTTP host
server {
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_name _;
  server_tokens off;

  ## Redirects all traffic to the HTTPS host
  return 301 https://$server_name:443$request_uri;
}


server
{
    listen 80;
		listen 443 ssl http2;
    server_name onlyoffice.tenfell.cn;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/onlyoffice.tenfell.cn;

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/xxx/fullchain.pem;
    ssl_certificate_key    /www/xxx/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header X-Content-Type-Options nosniff;
    location / {
      proxy_pass http://docservice;
      proxy_http_version 1.1;
    }
}

2.OnlyOffice安装教程

本次假设OnlyOffice和Webos在一台服务器上,这台服务器的外网IP为38.38.38.38,内网IP为192.168.0.103,OnlyOffice使用端口8001,Webos使用端口8088,OnlyOffice的密钥使用jwt123456,则步骤如下

1.先手动安装好Docker

​ \2. 使用命令安装好OnlyOffice

docker run -itd --name onlyoffice --restart=always -p 8001:80 --restart=always -e JWT_SECRET=jwt123456 onlyoffice/documentserver
docker run -itd --name onlyoffice --restart=always -p 8001:80 --restart=always -e JWT_SECRET=jwt123456 onlyoffice/documentserver

4.配置OnlyOffice

密钥填jwt123456

文档外网填http://38.38.38.38:8001

如果没有外网文档外网填 http://192.168.0.103:8001

文档内网填http://192.168.0.103:8001

系统内网填http://192.168.0.103:8088

然后点击检查按钮,当检查通过之后点保存即可

Webos 官方文档