質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

2回答

1509閲覧

awsのEC2上にてhttpアクセス時にフォルダを表示しないようにしたい

ma2hiro

総合スコア157

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/03/10 06:12

お世話になっております。

件名の通りやりたいのでググって調べると
/etc/httpd/conf/httpd.conf

Options Indexes FollowSymLinks

Options -Indexes FollowSymLinks
のようにすれば良いとの記事が見つかったので
そのようにしてリスタートした場合

# service httpd restart Redirecting to /bin/systemctl restart httpd.service Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

と上手くリスタート出来ません……

"systemctl status httpd.service" と "journalctl -xe"を見てって言われてみても

[root@ip-111-22-3-444 ~]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: failed (Result: exit-code) since Wed 2021-03-10 05:12:28 UTC; 2min 19s ago Docs: man:httpd.service(8) Process: 7197 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 7197 (code=exited, status=1/FAILURE) Status: "Reading configuration..." Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Starting The Apache HTTP Server... Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal httpd[7197]: AH00526: Syntax error on line 144 of /etc/httpd/conf/h...onf: Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal httpd[7197]: Either all Options must start with + or -, or no Option may. Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: httpd.service: main process exited, code=exited, status...LURE Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Failed to start The Apache HTTP Server. Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Unit httpd.service entered failed state. Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: httpd.service failed. Hint: Some lines were ellipsized, use -l to show in full. [root@ip-111-22-3-444 ~]# journalctl -xe -- -- The start-up result is done. Mar 10 05:30:01 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Starting Session 3820 of user root. -- Subject: Unit session-3820.scope has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit session-3820.scope has begun starting up. Mar 10 05:30:01 ip-111-22-3-444.ap-northeast-1.compute.internal CROND[7282]: (root) CMD (/usr/lib64/sa/sa1 1 1) Mar 10 05:30:01 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Removed slice User Slice of root. -- Subject: Unit user-0.slice has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit user-0.slice has finished shutting down. Mar 10 05:30:01 ip-111-22-3-444.ap-northeast-1.compute.internal systemd[1]: Stopping User Slice of root. -- Subject: Unit user-0.slice has begun shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit user-0.slice has begun shutting down. Mar 10 05:31:01 ip-111-22-3-444.ap-northeast-1.compute.internal dhclient[2850]: XMT: Solicit on eth0, interval 113200ms. Mar 10 05:32:54 ip-111-22-3-444.ap-northeast-1.compute.internal dhclient[2850]: XMT: Solicit on eth0, interval 122320ms.

と良く分からないため
調査方法をお伺いしてよろしいでしょうか?

お忙しい所失礼いたしますが何か情報をお持ちな方はコメント頂ければ幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/03/10 06:20

いろんなOSイメージがあるので、その点も触れてほしい。Amazon Linux 2なのか、CentOS 7や8なのか、Ubuntu 20.04なのかなど。
ma2hiro

2021/03/10 07:37

m6uさん 失礼しました。 AmazonLinuxを利用しております。
guest

回答2

0

ベストアンサー

Options Indexes FollowSymLinks

Options FollowSymLinks
としてみて下さい。

投稿2021/03/10 06:19

tanat

総合スコア18713

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ma2hiro

2021/03/10 07:44 編集

tanat様 コメントありがとうございます。 仰るように ```/etc/httpd/conf/httpd.conf #henkou Options Indexes FollowSymLinks Options FollowSymLinks ``` とすると [root@ip-111-22-3-444 ~]# service httpd restart Redirecting to /bin/systemctl restart httpd.service と無事リスタートは出来ました。ありがとうございます。 ですが http://111.22.33.4/~tesuto/hoge/ にアクセスすると ``` Index of /~tesuto/hoge ``` と表示されてしまうのです。 サーバーエラーとして返したいのですがなんという語句でググれば良いのかご助力頂けますと幸いです。
tanat

2021/03/10 07:57

ディレクトリに対しても同様の設定をしてあげればいいかと思います。 おそらく現状は、全体設定に対しての設定と、ディレクトリに対する設定が両方とも存在していて、ディレクトリに対する指定が優先されているんじゃないかという気がします。 検索キーワードとしては `apache(+バージョン名、httpd -vで2.2系か2.4系か確認してどちらかの数字を入れる) ファイル一覧 ディレクトリ指定`と`Apache(+バージョン名) Directoryディレクティブ` で、それぞれ個別に答えが書いてあるので、自分の環境に合わせて組み合わせる必要があります。 具体的には、 おそらく現状は https://httpd.apache.org/docs/2.4/ja/howto/public_html.html の様な形でユーザーディレクトリを設定していると思われるので(tesutoというユーザーが居そう) その部分の<Directory >の中に https://qiita.com/Yorcna/items/65b3a6a888bc7fd21e7f の FollowSymLinks のところで指定しているような形でオプションを指定してみて下さい。
ma2hiro

2021/03/12 09:19

tanatさん コメントありがとうございます。 私の説明が下手で混乱させて申し訳ございませんでした。 簡単に言えば http://hoge.site/~tesuto/fuga にアクセスした際に ``` Index of /~tesuto/fuga Parent Directory ``` と表示されそのフォルダの存在がバレないようにしたいのですが その際にhttpd.confにどのように表記すれば良いのかどのような語句で調べれば良いのか 取り掛かりをお教え頂けないでしょうか? お忙しい所大変申し訳無いのですが上記手助けして頂けますと嬉しく思います。
tanat

2021/03/12 09:25

> と表示されそのフォルダの存在がバレないようにしたいのですが その際にhttpd.confにどのように表記すれば良いのかどのような語句で調べれば良いのか その理解でのコメントですよ。 仮に現在使用されているApacheが2.4なのであれば、 `apach2.4 ファイル一覧 ディレクトリ指定` と `Apache2.4 Directoryディレクティブ` でそれぞれ検索して、内容を理解して組み合わせる必要があります。
ma2hiro

2021/03/15 01:29

/etc/httpd/conf.d の userdir.conf の Indexes を消せば ``` Forbidden You don't have permission to access this resource. ``` となるのですが出来れば ``` Not Found The requested URL was not found on this server. ``` としたいのです…… (+_+) 上記ご紹介して頂いた語句を検索して見比べてみます!
tanat

2021/03/15 01:33

Forbidden となるのが正しい挙動なのでそのままでいいと思いますよ。 どうしてもNot Foundにしたいのであれば、 https://www.javadrive.jp/apache/ini/index10.html を設定した上で、index.htmlを配置しないとかでしょうか。(あんまり意味が無いのでそういう設定をしたことが無いです)
ma2hiro

2021/03/15 01:36

失礼しました。 404じゃないとそのフォルダがあるのがバレるので セキュリティ上よろしくないと思い込んでいたようです…… 仰るように403で正しい挙動なのでこちらで運用していきます。 本当にありがとうございました。
guest

0

「Mar 10 05:12:28 ip-111-22-3-444.ap-northeast-1.compute.internal httpd[7197]: AH00526: Syntax error on line 144 of /etc/httpd/conf/h...onf:」が、なにかconfファイルを修正したことによってSyntax errorを引き起こしているので、httpd.conf文法チェックしましょう。

httpd - Apache Hypertext Transfer Protocol Server - Apache HTTP Server Version 2.4

httpd -t

でconfファイルの文法チェックができるはずです。

core - Apache HTTP サーバ バージョン 2.4

Optionsディレクティブでは、+や-をつけた表記とつけない表記の混在ができないようです。

Options で + や - のついたものを、つけないものと組み合わせて 指定する構文は正しい構文ではありませんので、期待する結果に ならないことがあります。

投稿2021/03/10 06:23

編集2021/03/10 06:27
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ma2hiro

2021/03/10 07:45

m6u様 コメントありがとうございます。 混合出来ないとの情報ありがとうございました。 URLや文法チェックもありがとうございます。 もう少し調べてみます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問