为tomcat代理应用程序获取404

3lxsmp7m  于 2021-10-10  发布在  Java
关注(0)|答案(1)|浏览(357)

我正在尝试设置tomcat服务器。
下面是我的virtualhost配置

<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+代理,因为它包含在readme.apache-proxy中,所以我基本上在指定的*.conf文件中添加了我的代理:

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

下面是my 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连接器正在侦听。请帮忙。我别无选择了。

c9x0cxw0

c9x0cxw01#

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

相关问题