How to install NextCloud on CyberPanel with Docker

NextCloud is open source software for mainly handling file hosting services. In this article we will see how to install NextCloud on CyberPanel with Docker. We will create NextCloud Docker container and then use rewirte rules to proxy traffic to this container.

Step 1: Open Docker on CyberPanel

In First Step open CyberPanel dashboard on your browser and look for Docker Manager, under Docker Manager you can click any link such as Manage Images, and it will redirect you to installation page (only if Docker is not already installed).

Step 2: Download/Pull NextCloud Image

Once Docker is installed now you have to search for NextCloud image. For the NextCloud image click on the Manage Images link, where you can easily search and pull the image. As you can see the search option in the landing page, here you can type NextCloud for image which is publicly available on Docker hub. Pull the Nextcloud image then image will be listed as locally available.

And select tag: docker.io/nextcloud:stable:apache, you can see NextCloud image is locally available after being pulled.

Step 3: Create Docker Container for Nextcloud Image

After installing Docker and pulling Nextcloud image, you are now ready to create your Docker Container for Nextcloud. Docker containers are just running instances of Docker Images.

Now click on the link of New Container under Docker Manager. Once the image and tag is selected hit the create button.

After Clicking Create button you will see the page below:

NextCloud image use **/var/www/**html to store the application data, you can map this as volume to your Docker Host, so that data is persisted between container reboots. We mapped this path to /home/nextcloud.cyberpanel.net/public_html/nextcloud.

In your case you can create website from CyberPanel and use its document root as path for volume mapping such as /home/yourdomain.com/public_html/nextcloud

We choose 9000 to be exposed as port from this container. Make sure that port you choose are not used by any other process. Finally click Create Container. If creation went successful you will be redirected to the container page where you can manage different aspects of container. By default container is in created state, you can click start to change its state to running.

Now that the container is running, you can use rewrite rules to proxy traffic to this container. Detailed instrucstions are available on the below article:

REVERSE PROXY TRAFFIC TO DOCKER CONTAINER ON CYBERPANEL

Make sure to use port 9000 in your proxy configurations, so that traffic is properly redirected to the container.

Once rewrite rules are configured, visit your domain and you should see the following page, you can then configure your NextCloud installation.

2 Likes

What should we pull on this step because there are several tags that we’re supposed to select before pulling to make NextCloud locally available?

Hello,

the SSL is not work for me, i edit my htaccess file as requested :
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ HTTP://dockerbackend/$1 [P]

the HTACCESS file is in /home/mydomain.com/public_html/

but NEXTCLOUD work on https
i get error : This site is inaccessible

I need HELP please to setup SSL on NEXTCLOUD

Try this

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And restart the server.

Thank you for your answer,

i try this but its not work also

it work on http you can see this :
http://cloud.dotkoncept.net:9000/

thank you in advance

You need to restart Openlitespeed or server after saving htaccess file

I restarted but without success

the HTACCESS file is in /home/mydomain.com/public_html/
the nextcloud folder is in /home/mydomain.com/public_html/nextcloud

The ssl is already working on your domain but not on the docker port.
I will find a workaround and update you soon.

1 Like

I installed nextcloud as described here.
Now I want to install jitsi with docker. I found some images but could not run them. What is the significance of the “ok/checked” mark in the image search/results list?

That was great my friend I followed every step and help me to get this work on cyberpanel
The problem for me as not familiar with docker container is how can I fix those Security & setup warnings

  1. There are some warnings regarding your setup.
    The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the documentation :arrow_upper_right:.
  2. SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: ‘occ db:convert-type’, or see the documentation :arrow_upper_right:.
  3. The “Strict-Transport-Security” HTTP header is not set to at least “15552000” seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips :arrow_upper_right:.
  4. Your web server is not properly set up to resolve “/.well-known/caldav”. Further information can be found in the documentation :arrow_upper_right:.
  5. Your web server is not properly set up to resolve “/.well-known/carddav”. Further information can be found in the documentation :arrow_upper_right:.
  6. Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.

I can fix 3, 4, 5 with standard installation but with containers I get confused plus I get 1 & 2 which I don’t have them on standard installation

Thank you

Hi, I too have this same issue. Looking forward to hearing solution.

Has anyone managed to get https access working with Nextcloud in a container?

I am getting an ssl error even after making the changes suggested here. > Error code: SSL_ERROR_RX_RECORD_TOO_LONG

I can access it fine without using ssl, but this means that Talk in Nextcloud wont work as that requires ssl.

Thanks in advance

Really? The majority of users here don’t know or use NextCloud? The free Nextcloud apps for Android, iOS, and desktop platforms allow you to sync and share data over an encrypted connection in a completely secure manner. The mobile clients support automatic uploading of photos and videos, as well as synchronisation of specific files and folders. So, hey man! Thank you so much for sharing on this thread on how to simply install NextCloud on CyberPanel with Docker.

Hello Mark,
By any chance did you get https working? If so how did you do it?
Thanks
tippy

In the above tutorial only port allowed is 80, if you want to access SSL you will need 443 port to be enabled.

Hello, how do I fix the imagick problem with nextcloud with Docker?
What do I have to do? Is it enough to install in cyberpanel? Or do I have to do it differently?

I get the installation working with fixing permissions but after 5 minutes the pages return 404.

So it did work for the first time after installing, but after 5 minutes it looks like it lost connection and gives back 404

Hi,

First thank you for your tutorial, everything working fine until I access to my URL to configure

I got an error

Can’t write into config directory!
This can usually be fixed by giving the webserver write access to the config directory.

I use ubuntu 22.04.2 LTS with everything up to date, mod security rule, CSF

I manage to get rid of the error by adjusting permition on nextcloud folder

Thanks

Any updates on this? The issues are still there.

Which os are you using ?