{"id":214,"date":"2017-08-10T08:23:38","date_gmt":"2017-08-10T08:23:38","guid":{"rendered":"http:\/\/blog.warbel.net\/?p=214"},"modified":"2017-08-11T02:02:09","modified_gmt":"2017-08-11T02:02:09","slug":"how-to-configure-collabora-with-nextcloud-behind-an-apache2-reverse-proxy","status":"publish","type":"post","link":"https:\/\/blog.warbel.net\/index.php\/2017\/08\/10\/how-to-configure-collabora-with-nextcloud-behind-an-apache2-reverse-proxy\/","title":{"rendered":"How to Configure Collabora with NextCloud behind an Apache2 Reverse Proxy"},"content":{"rendered":"<h1>Background:<\/h1>\n<p>I&#8217;ve become increasingly aware (read: paranoid) about the amount of information that Google and Facebook collect about me which they then sell to advertisers for a profit. I don&#8217;t appreciate Google reading my emails and personal communications and using that information to sell advertising. Unfortunately for me their services are useful but are replaceable, at leas for me with a fast NBN connection. As such I&#8217;ve set off to remove my self as much as possible from their reach.<\/p>\n<p>I&#8217;ve already setup <a href=\"https:\/\/mailinabox.email\/\">mailinabox<\/a> and <a href=\"https:\/\/www.nextcloud.com\">Nextcloud<\/a>, but I&#8217;ve missed the ability to edit documents online with Google Drive. Thankfully Nextcloud provide an answer with Collabora. Unfortunately <a href=\"https:\/\/nextcloud.com\/collaboraonline\/\">their documentation<\/a> isn&#8217;t very clear, however with a little playing around I was able to get things working. \ud83d\ude42<\/p>\n<h1>Process:<\/h1>\n<p>On my web server virtual machine, I installed docker and docker.io<\/p>\n<pre>sudo apt install docker docker.io<\/pre>\n<p>Download collabora:<\/p>\n<pre>sudo docker pull collabora\/code<\/pre>\n<p>As per the instructions, create a new subdomain (with letsencrypt) called office.warbel.net. If you use letsencrypt, you will need to create a new certificate inclusive of all your domains hosted on the web server.<\/p>\n<pre>sudo service apache2 stop\r\nsudo letsencrypt certonly -d bel.warbel.net -d www.warbel.net -d blog.warbel.net -d travel.warbel.net -d mattermost.warbel.net -d office.warbel.net\r\nsudo service apache2 start<\/pre>\n<p>Run the Collabora image. Being sure to run the image with the domain name of the server that hosts the image,\u00a0<strong>NOT\u00a0<\/strong><strong>office.yourdomain.net<\/strong><\/p>\n<pre>sudo docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=www\\\\.warbel\\\\.net' --restart always --cap-add MKNOD collabora\/code<\/pre>\n<p>Run the command to check the status of the image:<\/p>\n<pre>sudo docker ps<\/pre>\n<p>Will return: (the name will change, it is random)<\/p>\n<pre>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\r\n2e21004691d9 collabora\/code \"\/bin\/sh -c 'bash sta\" 3 days ago Up 3 days 127.0.0.1:9980-&gt;9980\/tcp boring_ardinghelli<\/pre>\n<p>To stop, and then kill the docker image:<\/p>\n<pre>sudo docker stop boring_ardinghelli; sudo docker rm boring_ardinghelli<\/pre>\n<p>Once you are confident that the image is up and running create a new site in \/etc\/apache2\/sites-available\/ and call it what you will. I called mine:\u00a0office.warbel.net.conf with the following configuration:<\/p>\n<pre>&lt;VirtualHost office.warbel.net:443&gt;\r\n\r\nServerName office.warbel.net\r\nSSLHonorCipherOrder on\r\n\r\n# Encoded slashes need to be allowed\r\nAllowEncodedSlashes NoDecode\r\n\r\n# Container uses a unique non-signed certificate\r\nSSLProxyEngine On\r\nSSLProxyVerify None\r\nSSLProxyCheckPeerCN Off\r\nSSLProxyCheckPeerName Off\r\n\r\n# keep the host\r\nProxyPreserveHost On\r\n\r\n# static html, js, images, etc. served from loolwsd\r\n# loleaflet is the client part of LibreOffice Online\r\nProxyPass \/loleaflet https:\/\/127.0.0.1:9980\/loleaflet retry=0\r\nProxyPassReverse \/loleaflet https:\/\/127.0.0.1:9980\/loleaflet\r\n\r\n# WOPI discovery URL\r\nProxyPass \/hosting\/discovery https:\/\/127.0.0.1:9980\/hosting\/discovery retry=0\r\nProxyPassReverse \/hosting\/discovery https:\/\/127.0.0.1:9980\/hosting\/discovery\r\n\r\n# Main websocket\r\nProxyPassMatch \"\/lool\/(.*)\/ws$\" wss:\/\/127.0.0.1:9980\/lool\/$1\/ws nocanon\r\n\r\n# Admin Console websocket\r\nProxyPass \/lool\/adminws wss:\/\/127.0.0.1:9980\/lool\/adminws\r\n\r\n# Download as, Fullscreen presentation and Image upload operations\r\nProxyPass \/lool https:\/\/127.0.0.1:9980\/lool\r\nProxyPassReverse \/lool https:\/\/127.0.0.1:9980\/lool\r\n\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>Finally, in nextcloud, add the plugin as per nextclouds documentation and add the domain office.yourdomain.com:443 to the collabora plugin url.<\/p>\n<h1>Troubleshooting:<\/h1>\n<p>I have a unique custom firewall script that interferes with docker.io. Docker, when it creates a container will add rules to it&#8217;s own chain. However my firewall script will delete those chains when it starts. The work around is to restart the docker.io service after the machine boots to recreate the chain and allow networking to start.<\/p>\n<p>I&#8217;ve also had to add custom firewall chains to my scripts to allow docker to work.These are (iptables -S):<\/p>\n<pre>-A FORWARD -j DOCKER-ISOLATION\r\n-A FORWARD -o docker0 -j DOCKER\r\n-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT\r\n-A FORWARD -i docker0 ! -o docker0 -j ACCEPT\r\n-A FORWARD -i docker0 -o docker0 -j ACCEPT\r\n-A DOCKER -d 172.17.0.2\/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 9980 -j ACCEPT\r\n-A DOCKER-ISOLATION -j RETURN<\/pre>\n<p>When the machine restarts I need to manually restart docker to get things going again. I&#8217;ll figure out how to fix this later&#8230;<\/p>\n<h2>Docker taking up too much space.<\/h2>\n<p>I&#8217;ve found that every time I&#8217;ve killed and started the docker image the space the image takes up remains. Some googling has helped me find a <a href=\"http:\/\/blog.yohanliyanage.com\/2015\/05\/docker-clean-up-after-yourself\/\">solution<\/a>:<\/p>\n<pre>docker rmi $(docker images -f \"dangling=true\" -q)<\/pre>\n<p>and<\/p>\n<pre>docker rm -v $(docker ps -a -q -f status=exited)<\/pre>\n<p>Do the job pretty well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background: I&#8217;ve become increasingly aware (read: paranoid) about the amount of information that Google and Facebook collect about me which they then sell to advertisers for a profit. I don&#8217;t appreciate Google reading my emails and personal communications and using &hellip; <a href=\"https:\/\/blog.warbel.net\/index.php\/2017\/08\/10\/how-to-configure-collabora-with-nextcloud-behind-an-apache2-reverse-proxy\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[15,13,12,14,16],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-apache2","tag-collabora","tag-docker","tag-nextcloud","tag-reverse-proxy"],"_links":{"self":[{"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/comments?post=214"}],"version-history":[{"count":5,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":219,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions\/219"}],"wp:attachment":[{"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.warbel.net\/index.php\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}