为 Tomcat 代理应用程序获取 404

Getting 404 for Tomcat Proxy Application

我正在尝试设置 Tomcat 服务器。

以下是我的虚拟主机配置

<VirtualHost <hosting's ip>:80>
  ServerName myapp.com
    ServerAlias mail.myApp.com www.myapp.com
#  DocumentRoot /home/myappco/public_html
  ServerAdmin webmaster@myapp.com
  UseCanonicalName Off

  <IfModule userdir_module>
    <IfModule !mpm_itk.c>
      <IfModule !ruid2_module>
        <IfModule !mod_passenger.c>
          UserDir enabled myappco
        </IfModule>
      </IfModule>
    </IfModule>
  </IfModule>
 <IfModule include_module>
    <Directory "/home/myappco/public_html">
      SSILegacyExprParser On
    </Directory>
  </IfModule>

  <IfModule suphp_module>
    suPHP_UserGroup myappco myappco
  </IfModule>
  <IfModule suexec_module>
    <IfModule !mod_ruid2.c>
      SuexecUserGroup myappco myappco
    </IfModule>
  </IfModule>
  <IfModule ruid2_module>
    RMode config
    RUidGid myappco myappco
  </IfModule>
  <IfModule mpm_itk.c>
    AssignUserID myappco myappco
  </IfModule>
  <IfModule mod_passenger.c>
    PassengerUser myappco
    PassengerGroup myappco
  </IfModule>

  <IfModule alias_module>
    ScriptAlias /cgi-bin/ /home/myappco/public_html/cgi-bin/
  </IfModule>
    <IfModule rewrite_module>
        RewriteOptions Inherit
    </IfModule>

    <IfModule proxy_fcgi_module>
        <FilesMatch \.(phtml|php[0-9]*)$>
            SetHandler proxy:unix:/opt/cpanel/ea-php71/root/usr/var/run/php-fpm/11fd7156a043fa23ad7e496c622a3f2dcd557177.sock|fcgi://myapp.com
        </FilesMatch>
    </IfModule>

  # To customize this VirtualHost use an include file at the following location
  Include "/etc/apache2/conf.d/userdata/std/2_4/myappco/myapp.com/*.conf"
</VirtualHost>

我正在学习本教程 https://documentation.cpanel.net/display/EA4/Tomcat+Proxies,因为它包含在 README.APACHE-PROXY 中,所以我基本上在指定的 *.conf 文件中添加了我的代理:

<IfModule proxy_ajp_module>
    ProxyPass "/myapp" "ajp://localhost:10001/myapp"
    ProxyPassReverse "/myapp" "ajp://localhost:10001/myapp"
</IfModule>

以下是我的server.xml

<?xml version="1.0" encoding="UTF-8"?>
<Server port="-1" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  <GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"/>
  </GlobalNamingResources>
  <Service name="Catalina">
<Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" deployOnStartup="true" deployXML="false">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b"/>
        <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false"/>
      </Host>
    </Engine>
    <Connector port="10001" protocol="AJP/1.3" xpoweredBy="false" secretRequired="false" enableLookups="true"/>
  </Service>
</Server>

看起来代理工作正常,因为我在 Chrome 开发工具中看到了 302 重定向状态,但是当它查询应用程序时我得到了 404,即使 Tomcat启动工作正常,表明 ajp 连接器正在侦听。请帮忙。我 运行 没有选择。

问题源于错误配置的 POM 文件,其中 index.html 文件被放置在 war 文件的其他位置。我只是更改了目标目录路径来解决此问题。为愚蠢的错误道歉。