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

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

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

TomcatはApache Software Foundation (ASF)で開発されたオープンソースのWebコンテナです。

Apache Tomcat

Apache TomcatはApache Software Foundation (ASF)で開発されたオープンソースのWebコンテナです。

Q&A

解決済

1回答

8570閲覧

Tomcat9 の manager の 「Server Status」「Manager App」にアクセスできない

reina.a

総合スコア9

Tomcat

TomcatはApache Software Foundation (ASF)で開発されたオープンソースのWebコンテナです。

Apache Tomcat

Apache TomcatはApache Software Foundation (ASF)で開発されたオープンソースのWebコンテナです。

0グッド

1クリップ

投稿2019/12/24 17:48

編集2019/12/24 18:02

Tomcat9 の manager の 「Server Status」「Manager App」にアクセスできません。
※403 Access Denied が表示されます。
※「Host Manager」にはアクセスできます。

■サーバ環境:
CentOS7
OpenJDK11
Tomcat 9 (9.0.30)

■設定内容:
アクセス環境を追加し、tomcat-users.xml にroleを下記のように追加しました。

対象ファイル:/opt/apache-tomcat/conf/tomcat-users.xml

<?xml version="1.0" encoding="UTF-8"?>

<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0">

<role rolename="manager-gui"/> <role rolename="manager-status"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="admin" password="password" roles="manager-gui,manager-status,manager-script,manager-jmx,admin-gui,admin-script"/> </tomcat-users>

role 部分を他のパターンに書き換えてみましたが、同様に「Host Manager」のみアクセスでき、
「Server Status」「Manager App」にアクセスできません。

○パターン1
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>

○パターン2
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="tomcat" password="s3cret" roles="tomcat"/>
<user username="both" password="s3cret" roles="tomcat,role1"/>
<user username="role1" password="s3cret" roles="role1"/>
<user username="manager" password="s3cret" roles="manager-gui,manager-status,manager-script,manager-jmx"/>
<user username="admin" password="s3cret" roles="admin-gui,admin-script"/>

■エラーメッセージ

403 Access Denied
You are not authorized to view this page.

By default the Manager is only accessible from a browser running on the same machine as Tomcat. If > > you wish to modify this restriction, you'll need to edit the Manager's context.xml file.

If you have already configured the Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site > request forgery (CSRF) protection that has been enabled for the HTML interface of the Manager application. You will need to reset this protection by returning to the main Manager page. Once you > return to this page, you will be able to continue using the Manager application's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application.

If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.

For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the > following to the config file listed above.

<role rolename="manager-gui"/> <user username="tomcat" password="s3cret" roles="manager-gui"/> Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from > the single manager role to the following four roles. You will need to assign the role(s) required for > the functionality you wish to access.

manager-gui - allows access to the HTML GUI and the status pages
manager-script - allows access to the text interface and the status pages
manager-jmx - allows access to the JMX proxy and the status pages
manager-status - allows access to the status pages only
The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the > CSRF protection:

Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.
If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces > are intended for tools not humans) then the browser must be closed afterwards to terminate the > session.
For more information - please see the Manager App How-To.

どのように設定を変更したよろしいでしょうか。
恐れ入りますがアドバイス頂けますと幸いです。
宜しくお願い致します。

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

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

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

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

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

rubytomato

2019/12/25 11:52

Tomcatはリモートサーバ上で稼働していて(たとえばクラウドなど)、ブラウザでアクセスするPCとは別でしょうか?
guest

回答1

0

ベストアンサー

Tomcat9 の 「Server Status」「Manager App」「Host Manager」に関して
インストール直後のデフォルト設定ではそれぞれアクセス権限がないようですので、
エラーページに記載されているようにロール(アクセス権限)とアクセス許可を設定することで
アクセスできるようになると思います。

設定変更後は Tomcat サービス再起動が必要。

ロール(アクセス権限)の設定例

  • /opt/apache-tomcat/conf/tomcat-users.xml

エラーページに例として記載されているロールを設定する。

<role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="tomcat" password="s3cret" roles="manager-gui,admin-gui"/>

アクセス許可の設定例

  • /opt/apache-tomcat/webapps/host-manager/META-INF/context.xml
  • /opt/apache-tomcat/webapps/manager/META-INF/context.xml

アクセス制限を無くしてしまう場合は以下コメントアウトする。

<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1" /> -->

アクセス元を追加する場合は既存設定にならい、|で区切ってアクセス許可するIPを追加する。
以下は 192.168. のIPを許可します。

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1|192.168.\d+.\d+" />

投稿2019/12/25 19:57

tchan

総合スコア19

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

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

reina.a

2020/01/29 06:09

回答ありがとうございました。 原因はアクセス制御で /opt/apache-tomcat/webapps/host-manager/META-INF/context.xml しか編集しておらず、 /opt/apache-tomcat/webapps/manager/META-INF/context.xml の編集が不足していた為でした。 おかげさまで無事に解決する事ができました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問