简体   繁体   English

Tomcat7允许访问管理器应用程序以进行多个主机配置

[英]Tomcat7 allow access to manager app for multiple hosts configuration

I have configured Tomcat7 (7.0.82) to host web apps for multiple host names by adding a Host entry for each domain in the server.xml file. 我已经通过在server.xml文件中为每个域添加一个主机条目,将Tomcat7(7.0.82)配置为为多个主机名托管Web应用程序。 This works as expected. 这按预期工作。 Below is my Engine definition in server.xml: 以下是我在server.xml中的引擎定义:

    <Engine defaultHost="localhost" name="Catalina">
        <Realm className="org.apache.catalina.realm.LockOutRealm">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
        </Realm>

        <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
        </Host>

        <Host appBase="xxx-webapps" autoDeploy="true" name="xxx.domain.com" unpackWARs="true">
        </Host>

        <Host appBase="yyy-webapps" autoDeploy="true" name="yyy.domain.com" unpackWARs="true">
        </Host>
    </Engine>

Now I want to enable access to the manager app for each Host. 现在,我想为每个主机启用对经理应用程序的访问。

A user is added to the tomcat-users.xml file in conf/. 将用户添加到conf /中的tomcat-users.xml文件中。

I have create a manager.xml file for each Host and placed these files in the respective domain-named subfolders in /conf, eg \\conf\\Catalina\\yyy.domain.com\\manager.xml. 我为每个主机创建了一个manager.xml文件,并将这些文件放在/ conf中相应的域名子文件夹中,例如\\ conf \\ Catalina \\ yyy.domain.com \\ manager.xml。 The contents of the manager.xml files are the same and contains only this information: manager.xml文件的内容相同,仅包含以下信息:

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="${catalina.home}/webapps/manager" 
    antiResourceLocking="false" privileged="true" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.0\.0\.1" />
</Context>

The manager app works when accessing it directly through localhost/manager , but I get the default 403 Access Denied immediately for the alternative Hosts on yyy.domain.com/manager ; 当直接通过localhost/manager访问管理器应用程序时,它可以工作,但是在yyy.domain.com/manager上,我立即获得备用主机的默认403访问被拒绝; no login prompt is shown. 没有显示登录提示。

Am I to refer to the tomcat-users.xml file from the manager.xml file or should I somehow create a reference in the manager.xml files to the UserDatabase defined within the Engine ? 我是要从manager.xml文件引用tomcat-users.xml文件,还是应该以某种方式在manager.xml文件中创建对Engine内定义的UserDatabase的引用?

Just remove the "Valve" tag. 只需删除“阀门”标签。 It's allow only "localhost" access (127.0.0.1). 它仅允许“本地主机”访问(127.0.0.1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM