📌

RancherOSでnextcloudを管理するテクニック

2 min read

次のdocker-compose.ymlを”スタックを追加”より実行

version: '2'

services:

  nextcloud:
    image: nextcloud:latest
    volumes_from:
      - nextcloud-data
    ports:
      - 4080:80
    depends_on:
      - mariadb
    labels:
      io.rancher.sidekicks: nextcloud-data
      io.rancher.container.hostname_override: container_name

  nextcloud-data:
    image: nextcloud:latest
    entrypoint:
      - /bin/true
    volumes:
      - /root/nextcloud:/var/www/html/config
    labels:
      io.rancher.container.start_once: 'true'
      io.rancher.container.hostname_override: container_name

  mariadb:
    image: mariadb:10
    environment:
      MYSQL_ROOT_PASSWORD: rootpass-nextcloud
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: nextcloud
    labels:
      io.rancher.sidekicks: mariadb-data
      io.rancher.container.hostname_override: container_name

  mariadb-data:
    image: mariadb:10
    entrypoint:
      - /bin/true
    volumes:
      - /var/lib/mysql
    tty: true
    labels:
      io.rancher.container.start_once: 'true'
      io.rancher.container.hostname_override: container_name

次のconfファイルをRancherOS外のapacheに設定

nextcloud.conf


<VirtualHost *:443>
	ServerName <your domain>.com
	SSLEngine on
	ServerAdmin webmaster@localhost
	SSLCertificateFile /etc/letsencrypt/live/<your domain>.com/cert.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/<your domain>.com/privkey.pem
	SSLCertificateChainFile /etc/letsencrypt/live/<your domain>.com/chain.pem
	
	ProxyPass / http://localhost:4080/
	ProxyPassReverse / http://localhost:4080/

	ErrorLog /var/www/logs/<your domain>.com/ssl-error.log
    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg.
    LogLevel warn
    CustomLog /var/www/logs/<your domain>.com/ssl-access.log combined
</VirtualHost>

CentOSならば

/etc/httpd/conf.d/

がデフォルトフォルダ

RancherOSにsshで接続して、次のファイルに追記

/root/nextcloud/config.php

  'overwritehost' => '<your domain>.com',
  'overwriteprotocol' => 'https',

これでうまくRancherOS上でnextcloudを管理しつつ、Let's Encryptで無料でhttps通信できる環境になる。

Discussion

ログインするとコメントできます