I have finally migrated from my local server to a server. Here is how I setup my own Nextcloud.
The Server
Once more we need a server. I use stratos Linux V40 Server for this. At 1€ for 3 Months and then 15€/Month it is not too expensive considering I get 1tb ssd diskspace, 32gb ram and 8 CPU vCores.
The Domain
I am still using namecheap. Since I already have a domain for my blog, i just created a subdomain (included) called cloud.mydomain.com
The Setup
Since I use Docker for my services here is what I used
The Stack
- Nextcloud
- MariaDB
- Traefik
Traefik
version: '3.7'
services:
traefik:
image: traefik
command:
- "--providers.docker"
- "--providers.docker.exposedByDefault=false"
- "--providers.docker.network=traefik"
- "--entrypoints.http.address=:80"
- "--entrypoints.http.http.redirections.entrypoint.to=https"
- "--entrypoints.http.http.redirections.entrypoint.scheme=https"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certResolver=le"
- "--certificatesresolvers.le.acme.tlschallenge=true"
- "--certificatesresolvers.le.acme.email=your@mail.com"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
networks:
- web
networks:
web:
name: traefik
Nextcloud/MariaDB
version: '3.7'
services:
nextcloud:
container_name: nextcloud
restart: unless-stopped
image: nextcloud
labels:
- 'traefik.enable=true'
- "traefik.http.routers.cloud.rule=Host(`cloud.yourdomain.com`)"
- 'traefik.http.services.nextcloud.loadbalancer.server.port=80'
- 'traefik.http.middlewares.header-nextcloud.headers.stsincludesubdomains=true'
- 'traefik.http.middlewares.header-nextcloud.headers.stspreload=true'
- 'traefik.http.middlewares.header-nextcloud.headers.stsseconds=15552000'
- 'traefik.http.middlewares.header-nextcloud.headers.customFrameOptionsValue=SAMEORIGIN'
- 'traefik.http.middlewares.header-nextcloud.headers.browserXssFilter=true'
- 'traefik.http.middlewares.header-nextcloud.headers.contentTypeNosniff=true'
- 'traefik.http.middlewares.header-nextcloud.headers.referrerPolicy=no-referrer'
- 'traefik.http.routers.nextcloud.middlewares=header-nextcloud'
networks:
- cloud
- traefik
volumes:
- ./apps:/var/www/html/apps
- ./config:/var/www/html/config
- ./data:/var/www/html/data
depends_on:
- db
# in nextcloud db web-setup enter maria-db.nextcould_cloud
db:
container_name: maria-db
restart: unless-stopped
image: mariadb
networks:
- cloud
env_file:
- cloud.env
volumes:
- ./mariadb:/var/lib/mysql
networks:
cloud:
traefik:
external: true
The .env-File
MYSQL_ROOT_PASSWORD='a_complex_admin_password'
MYSQL_DATABASE='what_do_you_call_your_database'
MYSQL_USER='Your_Custom_UserName'
MYSQL_PASSWORD='Custom_User_Password'
OVERWRITEPROTOCOL='https'
Run it
# start the traefik docker compose file
docker compose -f docker-compose.traefik.yml up -d
#start the nextcloud/MariaDB compose file
docker compose -f docker-compose.cloud.yml
If you now go to your cloud.yourdomain.com you will get a setup screen. Expand the DB-Section, select MariaDB, enter your credentials from your .env file (not the admin password!). And Voilá, you got yourself your very own cloud :)
Have fun.
Troubleshooting
Bug #1 - desktop client complains about polling url not being https
To fix this, on your server, go to the folder containing your nextcloud docker compose file. There should be a config folder if you started it once.
In that config folder go to the <php.config> file.
make sure these 3 lines are contained or add them
'trusted_domains' =>
array (
0 => 'cloud.yourdomain.com',
),
'overwrite.cli.url' => 'http://cloud.yourdomain.com',
'overwriteprotocol' => 'https',
Restart nextcloud once to activate the new config.
cd path/to/your/nextcloud/folder
docker compose -f docker-compose.cloud.yml down
docker compose -f docker-compose.cloud.yml up -d
Bug #2 - desktop client complains about bad json
This bug occured for me because I had another instance of nextcloud locally. Logout of your existing account and try again - that's it.