1. docker部署OnlyOffice环境
  2. 在前端项目index.html文件中加入外部js文件,链接必须为固定的ip或者域名,不可以用localhost或者127.0.0.1
<script type="text/javascript" src="https://onlyoffice.gudu.fun/web-apps/apps/api/documents/api.js"></script>
  1. 前端组件集成OnlyOffice,详见https://vue-demo.gudu.fun/OnlyOffice
  2. nginx转发OnlyOffice
server {
    listen      80;
    listen      443 ssl;
    server_name onlyoffice.gudu.fun;
	
    # 增加ssl
	ssl             on;
    ssl_certificate /ssl/onlyoffice.gudu.fun.pem;
    ssl_certificate_key /ssl/onlyoffice.gudu.fun.key;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    # 指定密码为openssl支持的格式
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    # 密码加密方式
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
    ssl_prefer_server_ciphers on;
	
	if ($scheme = http) {
		return 301 https://$server_name$request_uri;
	}

    location / {
        proxy_pass  http://ip:port;
        proxy_redirect     off;
        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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }
}
  1. 处理文档安全令牌未正确形成的问题
## 更改/etc/onlyoffice/documentserver/local.json
docker exec -it [容器id] bin/bash
cd /etc/onlyoffice/documentserver
sed -i 's/true/false/g' local.json
supervisorctl restart all

# To Be Continued!😎

Last Updated: 6/12/2023, 3:57:31 PM