1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Apacheのテストページを非表示にする

Posted at

はじめに

こんばんは、amaebiです。
自宅サーバーを構築して1、2か月が経ちました。
自宅サーバーで遊ぶのがほぼ日課になっている一方、1つ気になることが...

そう、毎回アクセスする度にテストページが表示されてしまうことなんです...
image.png

そこで、今回はテストページがうっとしいんでアクセスできないように設定しちゃいます!

各バージョン

  • OSバージョン : AlmaLinux 9.5 (Teal Serval)
  • Apacheバージョン : Apache/2.4.62

テストページ非表示設定

/etc/httpd/conf.d/welcome.confの下の設定内容をコメントアウトすることで非表示にすることができます。

welcome.conf(一部抜粋)
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /.noindex.html
</LocationMatch>

では、早速設定していきましょう。

/etc/httpd/conf.d/welcome.confを編集
# ls -la /etc/httpd/conf.d
# mkdir -v /etc/httpd/conf.d/.backup
# cp -ipv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/.backup/welcome.conf.`date +%Y%m%d`
# vi /etc/httpd/conf.d/welcome.conf
差分チェック
# diff -U0 /etc/httpd/conf.d/.backup/welcome.conf.<対象ファイルの日付> /etc/httpd/conf.d/welcome.conf 
--- /etc/httpd/conf.d/.backup/welcome.conf.<対象ファイルの日付>     2025-01-22 06:19:11.000000000 +0900
+++ /etc/httpd/conf.d/welcome.conf      2025-xx-xx xx:xx:xx.xxxxxxxxx +0900
@@ -8,4 +8,4 @@
-<LocationMatch "^/+$">
-    Options -Indexes
-    ErrorDocument 403 /.noindex.html
-</LocationMatch>
+#<LocationMatch "^/+$">
+#    Options -Indexes
+#    ErrorDocument 403 /.noindex.html
+#</LocationMatch>
# 
apache再起動
# systemctl restart httpd
# systemctl status httpd

http://<WebサーバーのIPアドレス>にアクセスしてみますが...
逆にサーバー情報がダダ漏れになってしまったので、こちらも修正します。
image.png

サーバー情報非表示設定

/etc/httpd/conf/httpd.confの部分を修正します。

httpd.conf(一部抜粋)
Options Indexes FollowSymLinks

設定していきます。

/etc/httpd/conf/httpd.confを編集
# ls -la /etc/httpd/conf
# mkdir -v /etc/httpd/conf/.backup
# cp -ipv /etc/httpd/conf/httpd.conf /etc/httpd/conf/.backup/httpd.conf.`date +%Y%m%d`
# vi /etc/httpd/conf/httpd.conf
差分確認
# diff -U0 /etc/httpd/conf/.backup/httpd.conf.<対象ファイルの日付> /etc/httpd/conf/httpd.conf 
--- /etc/httpd/conf/.backup/httpd.conf.<対象ファイルの日付> 2025-01-22 06:19:11.000000000 +0900
+++ /etc/httpd/conf/httpd.conf  2025-xx-xx xx:xx:xx.xxxxxxxxx +0900
@@ -149 +149 @@
-    Options Indexes FollowSymLinks
+    Options FollowSymLinks
# 
apache再起動
# systemctl restart httpd
# systemctl status httpd

もう一度、http://<WebサーバーのIPアドレス>にアクセスしてみます。
無事にForbiddenが表示され、ディレクトリ情報が非表示になりました!
image.png

さいごに

Apacheのテストページ非表示の設定手順でした。
テストページとお別れできたので、少し気分がよくなりました:blush:

参考資料

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?