Nextcloud8へアップグレード実施後に表示されたセキュリティ&セットアップ警告の対応を記事にしました。
・リバースプロキシサーバー debian12 nginx
・バックエンド Ubuntu22.04 apache2

.well-known
URL を解決するように適切に設定されておらず、失敗しました: /.well-known/caldav
詳細については、ドキュメント↗を参照してください。・一部のヘッダーがインスタンスで正しく設定されていません
– 「X-Content-Type-Options」HTTP ヘッダーが「nosniff」に設定されていません。これは潜在的なセキュリティまたはプライバシーのリスクであるため、この設定を適宜調整することをお勧めします。
– 「X-Robots-Tag」HTTP ヘッダーが「noindex,nofollow」に設定されていない。これは潜在的なセキュリティまたはプライバシーのリスクであるため、この設定を適宜調整することをお勧めします。ヘッダーが「sameorigin」に設定されていません。これは潜在的なセキュリティまたはプライバシーのリスクであるため、この設定を適宜調整することをお勧めします
– 「X-Permitted-Cross-Domain-Policies」HTTPヘッダーが「none」に設定されていません。これは潜在的なセキュリティまたはプライバシーのリスクであり、この設定を適宜調整することをお勧めします。
– 「X-XSS-Protection」HTTP ヘッダーには「1」が含まれていません。これは潜在的なセキュリティまたはプライバシーのリスクです。これに応じてこの設定を調整することをお勧めします。
– Referrer-Policy HTTP ヘッダーが no-referrer、no-referrer-when-downgrade、strict-origin’、strict-origin-when-cross-origin、または同じに設定されていません。 -起源 。これにより、リファラー情報が漏洩する可能性があります。 W3C 勧告を参照してください。詳細については、ドキュメントを参照してください。
リバースプロキシサーバーでの作業
[・Your web server is not properly set up to resolve `.well-known` URLs, failed on: `/.well-known/caldav` 詳細については、ドキュメント↗を参照してください。]の対応
Nextcloud用nginx設定ファイルを修正します。設定ファイル名は各々合わせてください。
sudo nano /etc/nginx/conf.d/nextcloud.conf
location /.well-known/carddav ブロックの行頭に#をつけてコメント化します。
location /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
# ↓ #
# location /.well-known/carddav {
# return 301 $scheme://$host/remote.php/dav;
# }
コメント化した location /.well-known/carddav ブロック下に rewrite ^/\.well-known/carddav https://$server_name/remote.php/dav/ redirect; を追加します。
# ↓ #
# location /.well-known/carddav {
# return 301 $scheme://$host/remote.php/dav;
# }
# コメント化した location /.well-known/carddav ブロック下に追加
rewrite ^/\.well-known/carddav https://$server_name/remote.php/dav/ redirect;
location /.well-known/caldav ブロックの行頭に#をつけてコメント化します。
location /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
# ↓ #
# location /.well-known/caldav {
# return 301 $scheme://$host/remote.php/dav;
# }
コメント化した location /.well-known/caldav ブロック下に rewrite ^/\.well-known/caldav https://$server_name/remote.php/dav/ redirect; を追加します。
# ↓ #
# location /.well-known/caldav {
# return 301 $scheme://$host/remote.php/dav;
# }
# コメント化した location /.well-known/caldav ブロック下に追加
rewrite ^/\.well-known/caldav https://$server_name/remote.php/dav/ redirect;
[Some headers are not set correctly on your instance – The ‘X-Content-Type-Options’ HTTP header is not set to ‘nosniff”. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly. – The ‘X-Robots-Tag’ HTTP header is not set to ‘noindex,nofollow’. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly. – The ‘X-Frame-Options’ HTTP header is not set to ‘sameorigin’. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly. – The ‘X-Permitted-Cross-Domain-Policies’ НТТР header is not set to ‘none’. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly. – The ‘X-XSS-Protection’ HTTP header does not contain ‘1; mode=block’. This is a potential security or privacy risk, as it is recommended to adjust this setting
accordingly. – The Referrer-Policy HTTP header is not set to no-referrer, no-referrer-when-downgrade, strict-origin’, strict-origin-when-cross-origin or same-origin . This can leak referer information. See the W3C Recommendation.詳細については、ドキュメントを参照してください。]の対応
Nextcloud用nginx設定ファイルを修正します。設定ファイル名は各々合わせてください。
sudo nano /etc/nginx/conf.d/nextcloud.conf
serverブロックへ以下追加します。
# serverブロックへ以下追加します。
add_header X-Content-Type-Options nosniff;
add_header X-Robots-Tag noindex,nofollow;
add_header X-Frame-Options sameorigin;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy no-referrer;
nginxを再起動します。
sudo systemctl restart nginx.service
バックエンドでの作業
[インデックスがありません。大きなテーブルにインデックスを追加すると、自動的に追加されないまでに時間がかかる可能性があるためです。”occ db:add-missing-indices”を実行することによって、インスタンスが実行し続けている間にそれらの欠けているインデックスを手動で追加することができます。インデックスが追加されると、それらのテーブルへのクエリは通常はるかに速くなります。オプションのインデックス “mailL_messages_strucanalyz_idx”がテーブル “mail_messages”にありません オプションのインデックス “mailL_class_creat_idx”
がテーブル “mail_classifiers”にありません オプションのインデックス “mail_acc_prov_idx”がテーブル “mail_accounts”にありませんオプションのインデックスデータベースにいくつかのインデックスがありません。大きなテーブルにインデックスを追加すると、自動的に追加されないまでに時間がかかる可能性があるためです。”occ db:add-missing-indices”を実行することによって、インスタンスが実行し続けている間にそれらの欠けているインデックスを手動で追加することができます。インデックスが追加されると、それらのテーブルへのクエリは通常はるかに速くなります。オプションのインデックス “mailL_messages_strucanalyz_idx”がテーブル “mail_messages”にありません オプションのインデックス “mailL_class_creat_idx”
がテーブル “mail_classifiers”にありません オプションのインデックス “mail_acc_prov_idx”がテーブル “mail_accounts”にありませんオプションのインデックス “mail_alias_accid_idx”がテーブル “mail_aliases”にありません オプションのインデックス “oc_npushhash_di”がテーブル “notifications_pushhash”にありません]の対応
セキュリティ&セットアップ警告 の画像には表示されていないメッセージです。
Nextcloudがインストールされているディレクトリに移動後、以下のコマンドを実行します。
sudo -u www-data php occ db:add-missing-indices
以上の作業で、Nextcloud Hub 8 (29.0.0)へアップグレード後に表示されたセキュリティ&セットアップ警告が消えました。

参考にさせていただいたサイト