zuntan02のはてなブログ

備忘録的なものです。時々職場の技術者ブログにも転記してますが、メインはこちらで。

【NextCloud】ver11→12への更新後に管理画面で出たセキュリティ警告対応

【概要】

EC2インスタンス上で動作させていたNextCloudをver.12に更新したところ、管理画面で以下の警告が出るようになった。

セキュリティ&セットアップ警告

It's important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the Tips & Ticks section and the documentation for more information.
"X-Frame-Options" HTTP ヘッダは "SAMEORIGIN" に設定されていません。これは潜在的なセキュリティリスクもしくはプライバシーリスクとなる可能性があるため、この設定を見直すことをおすすめします。

The PHP OPcache is not properly configured. For better performance we recommend to use following settings in the php.ini:
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
インストールガイド ↗をもう一度チェックして、ログ にあるエラーまたは警告について確認してください。

■"X-Frame-Options"ヘッダ対応

ブラウザの開発ツールを見ると以下の様にヘッダ値が重複している

X-Frame-Options	"SAMEORIGIN, SAMEORIGIN"

https://www.mozilla-japan.org/security/announce/2012/mfsa2012-51.html
によれば、
> X-Frame-Options: SAMEORIGIN, SAMEORIGIN のように X-Frame-Options ヘッダの値が
> 重複していた場合、そのヘッダ自体が無視されてしまう

→そもそもこのヘッダについて記述すべきでないという情報あり
https://github.com/nextcloud/server/issues/4863

→該当add_headerを削除(コメント)することで警告は出なくなった

     # add_header X-Frame-Options SAMEORIGIN;

PHP OPcache設定

# php-opcacheをインストール

yum install php-opcache
# Installed:
#   php56-opcache.x86_64 0:5.6.30-1.133.amzn1

service php-fpm restart
service nginx restart

→まだ警告文が出ている

php -i | grep opcache
(以下抜粋)
opcache.enable_cli => Off => Off
opcache.max_accelerated_files => 4000 => 4000
opcache.revalidate_freq => 2 => 2

→上記を指定の値に修正
vi /etc/php.d/10-opcache.ini

diff /etc/php-5.6.d/10-opcache.ini /etc/php-5.6.d/10-opcache.ini_org
8c8
< opcache.enable_cli=1
---
> ;opcache.enable_cli=0
18c18
< opcache.max_accelerated_files=10000
---
> opcache.max_accelerated_files=4000
36c36
< opcache.revalidate_freq=1
---
> ;opcache.revalidate_freq=2

こちらも警告は出なくなった