はじめに
Docker Compose環境でNextcloudのストレージにMinIOを採用した際、Internalエラーが発生してログインできなくなってしまいました。
ここではこのエラーを解消する方法について紹介します。
環境
- Nextcloud: nextcloud:28.0.1-apache
- MinIO: quay.io/minio/minio:RELEASE.2024-01-29T03-56-32Z
発生したエラー
上記タグのDockerコンテナを立てました。なおポートを開放しているため、それぞれのコンテンツにアクセスできることは確認済みです。
Nextcloudにアクセスし、管理者アカウントでログインしようとした所、エラー画面が表示されました。
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
また、MinIOブラウザにアクセスしてみましたが、作成されているはずのバケットが作成されていませんでした。
以下はNextcloudのログです。
$ less /data/nextcloud.log
{"reqId":"lMkHVJkvN090IGtsL4KZ","level":3,"time":"2024-02-04T09:10:12+00:00","remoteAddr":"","user":"admin","app":"objectstore","method":"","url":"--","message":"Could not create object urn:oid:4 for files/Documents/Welcome to Nextcloud Hub.docx","userAgent":"--","version":"28.0.1.1","exception":{"Exception":"Exception","Message":"Creation of bucket \"nextcloud\" failed. Error executing \"CreateBucket\" on \"http://nextcloud.nextcloud-storage:9000/\"; AWS HTTP error: cURL error 6: Could not resolve host: nextcloud.nextcloud-storage (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://nextcloud.nextcloud-storage:9000/","Code
# 以下略
http://nextcloud.nextcloud-strage:9000
というURLに対してリクエストを送ってしまっているようです。検証の結果、http://<バケット名>.<コンテナ名>:9000
に対してリクエストを送っていることが判明しました。
今回はDocker Composeで環境を整えているので、http://<コンテナ名>:9000
に対してリクエストを送ることができれば解消できそうです。
エラーの解消方法
OBJECTSTORE_S3_USEPATH_STYLE
環境変数をtrueに設定します。
services:
nextcloud:
image: nextcloud:28.0.1-apache
depends_on:
- nextcloud-storage
ports:
- 8080:80
environment:
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
OBJECTSTORE_S3_HOST: nextcloud-storage
OBJECTSTORE_S3_BUCKET: nextcloud
OBJECTSTORE_S3_KEY: minio
OBJECTSTORE_S3_SECRET: minio123
OBJECTSTORE_S3_REGION: us-east-1
OBJECTSTORE_S3_USEPATH_STYLE: true # 追加
OBJECTSTORE_S3_PORT: 9000
OBJECTSTORE_S3_SSL: false
OBJECTSTORE_S3_AUTOCREATE: true
環境変数を編集後、再度ログインを試すと、エラーが発生することもなく、MinIOにもバケットが作成されていました。
エラーが発生した状況
以下はエラーが発生した際のcompose.ymlになります。
services:
nextcloud:
image: nextcloud:28.0.1-apache
depends_on:
- nextcloud-storage
ports:
- 8080:80
environment:
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
OBJECTSTORE_S3_HOST: nextcloud-storage
OBJECTSTORE_S3_BUCKET: nextcloud
OBJECTSTORE_S3_KEY: minio
OBJECTSTORE_S3_SECRET: minio123
OBJECTSTORE_S3_REGION: us-east-1
OBJECTSTORE_S3_PORT: 9000
OBJECTSTORE_S3_SSL: false
OBJECTSTORE_S3_AUTOCREATE: true
nextcloud-storage:
image: quay.io/minio/minio:RELEASE.2024-01-29T03-56-32Z
ports:
- 9000:9000
- 9001:9001
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
command: server /data --console-address ":9001"
エラーが発生した原因
OBJECTSTORE_S3_USEPATH_STYLE
環境変数を設定していないことが原因でした。
この環境変数をtrueに設定することによって、Nextcloudはhttp://nextcloud-storage/nextcloud:9000
に対してリクエストを送るようになります。
以下のドキュメントに詳細が載っています。
If you using a non-Amazon hosted S3 store: you will need to set the hostname parameter (and can ignore the region parameter). You may need to use use_path_style if your non-Amazon S3 store does not support requests like https://bucket.hostname.domain/. Setting use_path_style to true configures the S3 client to make requests like https://hostname.domain/bucket instead.
まとめ
今回はDocker Compose環境でNextcloudのストレージにMinIOを採用した際に発生したエラーについてまとめました。