简体   繁体   中英

Redirect apache httpd to tomcat by mod_jk on centos 8

Im trying to force apache httpd to redirect some requests to tomcat. I'm using mod_jk. My testapp is reachable via https://www.myDomain.pl:8443/testapp but apache httpd returns 404 if run via https://www.myDomain.pl/testapp .

What am I doing wrong? Help pls

Here are my configuration files changes:

/usr/local/tomcat9/conf/server.xml

 <Connector protocol="AJP/1.3"
            address="127.0.0.1"
           port="8009"
           redirectPort="8443"
            secretRequired="false"/>

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true">
    <SSLHostConfig>
            <Certificate certificateKeyFile="conf/server.key"
                     certificateFile="conf/server.crt"
                     certificateChainFile="conf/server.ca"
                     type="RSA" />
             </SSLHostConfig>
</Connector>

/etc/httpd/conf/httpd.conf

LoadModule jk_module /usr/lib/apache/mod_jk.so

JkWorkersFile "/etc/httpd/conf/workers.properties"
JkLogFile     "/var/log/mod_jk.log"
JkLogLevel  info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat     "%w %V %T"
JkShmFile     /var/log/httpd/mod_jk.shm

/etc/httpd/conf/workers.properties (whole file)

worker.list=a
worker.a.type=ajp13
worker.a.host=localhost
worker.a.port=8009
worker.a.socket_timeout=10

/etc/httpd/conf/extra/httpd-vhosts.conf (whole file)

  <VirtualHost myIP:80>
    ServerAdmin webmaster@localhost
    UserDir disabled
    DocumentRoot /var/www/html
    ServerName www.myDomain.pl
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/homedir.log homedir
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    <IfModule !mod_ruid2.c>
        SuexecUserGroup webapps webapps
    </IfModule>
</VirtualHost>

<VirtualHost myIP:443 >
    ServerAdmin webmaster@localhost
    UserDir disabled
    DocumentRoot /var/www/html
    ServerName www.myDomain.pl
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/homedir.log homedir
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    SSLEngine on
    SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
    SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
    SSLCACertificateFile /etc/httpd/conf/ssl.crt/server.crt
JkMount /testapp a
    <IfModule !mod_ruid2.c>
        SuexecUserGroup webapps webapps
    </IfModule>
</VirtualHost>

I'm not sure what could be your problem but I would try changing

JkMount /testapp a

to

JkMount / a

Moreover, have you considered using ProxyPass and ProxyPassReverse (https://tomcat.apache.org/connectors-doc-archive/jk2/proxy.html )?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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