ReinerNippes / nextcloud

Ansible playbook to install nextcloud, php, nginx or apache, mariadb or postgres, redis-server, onlyoffice or collabora office
MIT License
412 stars 141 forks source link

onlyoffice not working #15

Closed changchichung closed 4 years ago

changchichung commented 6 years ago

I add this section to nextcloud config.php

  'preview_max_x' => '1024',
  'preview_max_y' => '768',
  'preview_max_scale_factor' => '1',
  'auth.bruteforce.protection.enabled' => 'true',
  'trashbin_retention_obligation' => 'auto,7',
  'skeletondirectory' => '',
  'defaultapp' => 'file',
  'activity_expire_days' => '14',
  'integrity.check.disabled' => 'false',
  'updater.release.channel' => 'stable',
  'loglevel' => 2,
  'maintenance' => false,
  'onlyoffice' =>
  array (
    'verify_peer_off' => true,
  ),
);

docker status

root@hqs235:/var/www/nextcloud/config# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                      PORTS                                  NAMES
bb80aec8442f        onlyoffice/documentserver   "/bin/sh -c /app/onl…"   38 minutes ago      Up 38 minutes               80/tcp, 192.168.11.235:8443->443/tcp   onlyoffice
0c39e70ccd40        paulczar/omgwtfssl          "/bin/sh -c /usr/loc…"   16 hours ago        Exited (0) 39 minutes ago                                          omgwtfssl
ee49d13d17a7        postgres:alpine             "docker-entrypoint.s…"   16 hours ago        Up About an hour            127.0.0.1:5432->5432/tcp               postgres
root@hqs235:/var/www/nextcloud/config# 

I modify the playbook , change onlyoffice export port

- name: start a onlyoffice container
  docker_container:
    name: onlyoffice
    image: onlyoffice/documentserver
    state: started
    restart: yes
    restart_policy: always
    interactive: true
    tty: yes
    ports:
     - "192.168.11.235:8443:443"

But I can not connect to 192.168.11.35:8443

2018-10-18 02:36:00 [minion@hqs235 nextcloud]$ telnet 192.168.11.235 8443
Trying 192.168.11.235...
telnet: Unable to connect to remote host: Connection refused
2018-10-18 02:38:24 [minion@hqs235 nextcloud]$ 

but if I expose onlyoffice port 80 , I can open that page . http://i.imgur.com/DcKuoxz.png

docker logs onlyoffice

 * Starting PostgreSQL 9.5 database server                               [ OK ] 
 * Starting RabbitMQ Messaging Server rabbitmq-server                    [ OK ] 
Starting redis-server: redis-server.
Starting supervisor: supervisord.
 * Starting periodic command scheduler cron                              [ OK ] 
 * Starting nginx nginx                                                  [ OK ] 
Generating AllFonts.js, please wait...Done
onlyoffice-documentserver:docservice: stopped
onlyoffice-documentserver:docservice: started
onlyoffice-documentserver:converter: stopped
onlyoffice-documentserver:converter: started
 * Reloading nginx configuration nginx                                   [ OK ] 
==> /var/log/onlyoffice/documentserver/converter/err.log <==

==> /var/log/onlyoffice/documentserver/converter/out.log <==
[2018-10-18 02:27:43.667] [WARN] nodeJS - update cluster with 1 workers
[2018-10-18 02:27:43.685] [WARN] nodeJS - worker 704 started.
[2018-10-18 02:27:43.685] [WARN] nodeJS - update cluster with 1 workers
[2018-10-18 02:27:48.291] [WARN] nodeJS - update cluster with 1 workers
[2018-10-18 02:27:48.297] [WARN] nodeJS - worker 766 started.
[2018-10-18 02:27:48.298] [WARN] nodeJS - update cluster with 1 workers

==> /var/log/onlyoffice/documentserver/docservice/err.log <==

==> /var/log/onlyoffice/documentserver/docservice/out.log <==
[2018-10-18 02:27:47.786] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode
[2018-10-18 02:28:00.011] [ERROR] nodeJS - expireDoc error:
TypeError: Cannot read property 'time' of null
    at collectStats (/var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:2659:55)
    at collectStats.next (<anonymous>)
    at /var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:2717:16
    at Generator.next (<anonymous>)
    at onFulfilled (/var/www/onlyoffice/documentserver/server/DocService/node_modules/co/index.js:65:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

==> /var/log/onlyoffice/documentserver/gc/err.log <==

==> /var/log/onlyoffice/documentserver/gc/out.log <==

==> /var/log/onlyoffice/documentserver/metrics/err.log <==

==> /var/log/onlyoffice/documentserver/metrics/out.log <==
18 Oct 02:27:42 - [600] reading config file: ../../config/config.js
18 Oct 02:27:42 - server is up INFO

==> /var/log/onlyoffice/documentserver/nginx.error.log <==

==> /var/log/onlyoffice/documentserver/spellchecker/err.log <==

==> /var/log/onlyoffice/documentserver/spellchecker/out.log <==
[2018-10-18 02:27:42.869] [WARN] nodeJS - start cluster with 1 workers
[2018-10-18 02:27:42.890] [WARN] nodeJS - worker 672 started.
[2018-10-18 02:27:44.335] [WARN] nodeJS - Express server starting...
[2018-10-18 02:27:44.509] [WARN] nodeJS - Express server listening on port 8080 in production-linux mode

==> /var/log/onlyoffice/documentserver/metrics/out.log <==
Flushing stats at  Thu Oct 18 2018 02:37:43 GMT+0000 (UTC)
{ counters: 
   { 'statsd.bad_lines_seen': 0,
     'statsd.packets_received': 0,
     'statsd.metrics_received': 0 },
  timers: {},
  gauges: {},
  timer_data: {},
  counter_rates: 
   { 'statsd.bad_lines_seen': 0,
     'statsd.packets_received': 0,
     'statsd.metrics_received': 0 },
  sets: {},
  pctThreshold: [ 90 ] }

any suggestions ?

ReinerNippes commented 6 years ago

what is the aim of your modifications?

changchichung commented 6 years ago

sorry for late reply , I change the export to add IP , bcz if dont , then the expose port only works on ipv6 , i f I enable ipv6 interface. ( is that what you ask ?)

I pull another onlyoffice container from onlyoffice/documentserver https://hub.docker.com/r/onlyoffice/documentserver/ and follow the steps to make self-signed certification file then change to nextcloud settings , point onlyoffice url to the new onlyoffice container , and it works !

I will try to create a new VPS and try your playbook again , thanks !

changchichung commented 6 years ago

I just create a new VPS run this playbook with letsencrypt , everything works like a charm , thanks ! I guess there`s still something to be adjusted when using self-signed certification , and I will try to keep working on this , any suggestions ?

jcklpe commented 6 years ago

@ReinerNippes Is it possible to run the playbook in such a way as it just adds the only office support? I would like to use the OnlyOffice Document server and integration and if it's possible to do so using a portion of your playbook that would be super useful for me on my already existing installation.

ReinerNippes commented 6 years ago

@jcklpe you may try to download https://github.com/ReinerNippes/nextcloud/blob/master/only_office.yml into the directory of the nextcloud playbook. and run ansible-playbook only_office.yml make a backup before. ;-)

ReinerNippes commented 6 years ago

@changchichung i know that my playbook is not creating the correct self signed certificates for onlyoffice. up to now i didn't have the time to correct this. sorry. it's in my backlog.

changchichung commented 6 years ago

I had test for several times for make self signed certification work , here is what I changed

  1. make self sign certs ( which playbook already do in role prep_selfssl)
  2. add ssl settings with these certs in nginx.conf (which playbook already do role prep_selfssl)
  3. add nextcloud hostname record to /etc/hosts
  4. change the onlyoffice default.json , ref to https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/96

I will try to modify the playbook using lineinefile or copy or template module in ansible.

hoerup commented 6 years ago

I exposed 8080 => 80 (i run it behind a proxy with SSL offload anyways) and i can confirm that there is a issue related to setting the secret (but when i removed secret from nextcloud/onlyoffice config page everything worked)

Update: rerun the setup an using exposed http - but secret from the script, everything worked

jcklpe commented 6 years ago

Hey just wanted to let ya'll know I installed OnlyOffice to an already existing NextCloud installation, and it worked wonderfully! Thank you Reiner for all this awesome work :D

jsanfe commented 5 years ago

Hey just wanted to let ya'll know I installed OnlyOffice to an already existing NextCloud installation, and it worked wonderfully! Thank you Reiner for all this awesome work :D

i would ask.... How you did it?

jcklpe commented 5 years ago

@jsanfe Through the instruction that Reiner gave here:

@jcklpe you may try to download https://github.com/ReinerNippes/nextcloud/blob/master

/only_office.yml into the directory of the nextcloud playbook. and run ansible-playbook only_office.yml make a backup before. ;-)

if you have any other questions let me know.

ReinerNippes commented 5 years ago

@jsanfe it only works if you have installed your nextcloud with my playbook before.

jsanfe commented 5 years ago

@jsanfe Through the instruction that Reiner gave here:

@jcklpe you may try to download https://github.com/ReinerNippes/nextcloud/blob/master

/only_office.yml into the directory of the nextcloud playbook. and run ansible-playbook only_office.yml make a backup before. ;-)

if you have any other questions let me know.

I did it, but now I think have to fill more info (onlyoffice conector), SSL and secret key...

@jsanfe it only works if you have installed your nextcloud with my playbook before.

I tryed your playbook, but I had a lot of issues, so I decided to install nextcloudPi then here's what I did next: Install your clone https://github.com/ReinerNippes/nextcloud/blob/master exec ansible-playbook only_office.yml into nextcloud directory. and does not work. This night I will do a fresh Debian 10 install and try again all the process. Thanks for reading and support!

ReinerNippes commented 5 years ago

The playbook is meant to be executed on an empty, fresh linux installation. I can't foresee all eventuality and situation that could happen when another app/service is already installed.

What kind of issues did you encounter during first run?

jsanfe commented 5 years ago

What kind of issues did you encounter during first run?

fresh Debian 10

installing curl... ok installing prepare.sh--- Fail:

 ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-TPXlix/python-apt/setup.py'"'"'; __file__='"'"'/tmp/pip-install-TPXlix/python-apt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-TPXlix/python-apt/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-TPXlix/python-apt/setup.py", line 6, in <module>
        from DistUtilsExtra.command import *
    ImportError: No module named DistUtilsExtra.command
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

error prepare_sh

Next steps...

git clone https://github.com/ReinerNippes/nextcloud
cd nextcloud
nano inventory (just add onlyoffice=true)
./nextcloud.yml

Error:

PLAY [install nextcloud] **************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
Tuesday 03 September 2019  22:26:52 +0200 (0:00:00.466)       0:00:00.467 *****
fatal: [localhost]: FAILED! => changed=false
  ansible_facts: {}
  failed_modules:
    setup:
      ansible_facts:
        discovered_interpreter_python: /usr/bin/python
      failed: true
      module_stderr: |-
        /bin/sh: 1: sudo: not found
      module_stdout: ''
      msg: |-
        MODULE FAILURE
        See stdout/stderr for the exact error
      rc: 127
      warnings:
      - Platform linux on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html for more information.
  msg: |-
    The following modules failed to execute: setup

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Tuesday 03 September 2019  22:26:53 +0200 (0:00:01.108)       0:00:01.575 *****
===============================================================================
Gathering Facts ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1.11s

Fresh Debian 9

Same error executing prepare.sh

 ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-XKIlM0/python-apt/setup.py'"'"'; __file__='"'"'/tmp/pip-install-XKIlM0/python-apt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-XKIlM0/python-apt/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-XKIlM0/python-apt/setup.py", line 6, in <module>
        from DistUtilsExtra.command import *
    ImportError: No module named DistUtilsExtra.command
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

   Debian Sytem ready for nextcloud.

ansible 2.8.4
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]

```root@debian:/home/sanfe# git clone https://github.com/ReinerNippes/nextcloud
git clone https://github.com/ReinerNippes/nextcloud
cd nextcloud
nano inventory (just add onlyoffice=true)
./nextcloud.yml -e fqdn=xxxx.serveftp.com -e ssl_certificate_type=selfsigned

working but when finished:

TASK [prep_postgres : create nextcloud db] ********************************************************************************************************************************************************************
Wednesday 04 September 2019  00:30:29 +0200 (0:00:00.649)       0:04:57.424 ***
fatal: [localhost]: FAILED! => changed=false
  module_stderr: |-
    /bin/sh: 1: sudo: not found
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 127

RUNNING HANDLER [prep_ufw : reload ufw] ***********************************************************************************************************************************************************************
Wednesday 04 September 2019  00:30:30 +0200 (0:00:00.684)       0:04:58.108 ***

RUNNING HANDLER [prep_nginx : restart nginx] ******************************************************************************************************************************************************************
Wednesday 04 September 2019  00:30:30 +0200 (0:00:00.000)       0:04:58.109 ***

RUNNING HANDLER [prep_redis : restart redis-server] ***********************************************************************************************************************************************************

Wednesday 04 September 2019  00:30:30 +0200 (0:00:00.000)       0:04:58.110 ***

RUNNING HANDLER [prep_php : restart php-fpm] ******************************************************************************************************************************************************************
Wednesday 04 September 2019  00:30:30 +0200 (0:00:00.000)       0:04:58.111 ***

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost                  : ok=58   changed=41   unreachable=0    failed=1    skipped=14   rescued=0    ignored=0

Wednesday 04 September 2019  00:30:30 +0200 (0:00:00.003)       0:04:58.114 ***
===============================================================================
prep_php : install additional packages ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 54.73s
prep_nginx : install additional packages -------------------------------------------------------------------------------------------------------------------------------------------------------------- 44.54s
prep_postgres : apt install postgresql-client with Update --------------------------------------------------------------------------------------------------------------------------------------------- 34.82s
prep_os : install additional packages ----------------------------------------------------------------------------------------------------------------------------------------------------------------- 33.66s
prep_php : apt dist-upgrade --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 15.61s
prep_ufw : Installing ufw package --------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14.31s
prep_nginx : add additional debian repos --------------------------------------------------------------------------------------------------------------------------------------------------------------- 9.75s
prep_redis : install additional packages --------------------------------------------------------------------------------------------------------------------------------------------------------------- 7.10s
prep_postgres : add postgresql to sources list --------------------------------------------------------------------------------------------------------------------------------------------------------- 5.94s
prep_ufw : Configuring port/protocol/network rules ----------------------------------------------------------------------------------------------------------------------------------------------------- 5.89s
prep_postgres : add postgres repo key ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 5.64s
prep_nginx : add nginx key ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5.35s
prep_php : add additional repos ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 5.31s
prep_php : add sury.org/php key ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 4.92s
prep_postgres : install psycopg2 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4.45s
Gathering Facts ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.13s
prep_ufw : Configuring service ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.46s
prep_os : apt dist-upgrade ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.28s
prep_nginx : apt dist-upgrade -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.27s
prep_nginx : copy some nginx config file --------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.25s
root@debian:/home/sanfe/nextcloud#  [WARNING]: Updating cache and auto-installing missing dependency: python-apt
bash: [WARNING]:: no se encontró la orden
root@debian:/home/sanfe/nextcloud#
ReinerNippes commented 5 years ago

/bin/sh: 1: sudo: not found

is sudo installed and root in sudo allowed?

jsanfe commented 5 years ago

Ok ReinerNippes... First, i want to give you thanks for your pacience and support. Second. I had installed now sudo, (i didnt know i had to), until now, i ran all the commands as Super User. Third... Ive executed your script, and now i have 0 errors O_o. Nextcloud seems to works ok. (Thanks) Fourth, i tryed to test onlyoffice, but when i clic into new word document, one window says: ONLYOFFICE cannot be reached. Please contact admin. I will make more test this night. Thanks!!!!!

ReinerNippes commented 5 years ago

the default become method of ansible is 'sudo'. nevertheless you can define your own method by adding '--become-method=[ sudo | su | pbrun | pfexec | doas | dzdo | ksu ]' https://docs.ansible.com/ansible/2.3/become.html that might have been an option as well. i never tested it.

if you use selfsigned certificates this playbook don't work. the two playbook with docker do. it's still on my list to figure out how to configure nextcloud and onlyoffice.

jsanfe commented 5 years ago

Let me try this night or meaby tomorrow with lets encrypt. Every day is good to keep learning. Regards!

jsanfe commented 5 years ago

Morning! I have some problems with debian 10: imagen I try with diferents ports, but i had the same issue...

ReinerNippes commented 5 years ago

it's not a problem of the port. there is a problem with the command sudo /sbin/ufw status verbose. can you configure and open port 80/443 manully with ufw on this machine?

jsanfe commented 5 years ago

Now i have all working (nextcloud and onlyoffice) but with debian 9, and i upload a lot of data inside, so i will test in another machine.