0

I'm having problems moving my Apache mod_jk configuration form its own VirtualHost configuration into my main ssl VirtualHost configuration.

Tomcat is working ok using its own domain using mod_jk and a VirtualHost configuration - working config....

LoadModule jk_module  /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkShmFile     /var/log/httpd/mod_jk.shm
JkLogFile     /var/log/httpd/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

<VirtualHost *:80>
    ServerName <my cname>
    DocumentRoot /opt/appserver/webapps/ROOT
    DirectoryIndex index_page.jsp       

    <Directory />
                Options FollowSymLinks
                AllowOverride None
    </Directory>

    <Directory /opt/appserver/webapps/ROOT>
                AllowOverride None
                Options FollowSymLinks
                Order allow,deny
                allow from all
    </Directory>

    JkMount /* ajp13
</VirtualHost>

however because I want to embed my Tomcat forms in my main server pages which are ssl (can't mix http and https) I need to move my mod_jk configuration into my main ssl VirtualHost as a subfolder. I've tried the following changes, but I get a Tomcat error 'HTTP Status 404 - /servlet/' when trying to access https://

New server config:

<VirtualHost _default_:443>

...lots of my main ssl server config stuff...

Alias /servlet /opt/appserver/webapps/ROOT

JkMount /servlet/* ajp13

<Directory /opt/appserver/webapps/ROOT>
        AllowOverride None
        Options FollowSymLinks
        Order allow,deny
        allow from all
        DirectoryIndex index_page.jsp
</Directory>

</VirtualHost>
Brian
  • 83
  • 1
  • 7
  • plz post mod-jk, httpd and tomcat log to know the exact problem – Ghayel Jan 28 '16 at 09:25
  • There are no tomcat logs for a page request. There is a 404 log in ssl_access_log, but the 404 message rendered to the browser is from tomcat (it has a 'Apache Tomcat/7.0.59' footer). – Brian Jan 28 '16 at 10:08

2 Answers2

0
  1. Make sure your domain certificate is generated accurately
  2. Copy *key.pem and *cert.pem within /etc/apache2/ directory
  3. write the following

<VirtualHost _default_:443> DocumentRoot "/opt/appserver/webapps/Your-Project-Directory" ServerName YourDomain.com ErrorLog "/var/log/apache2/https_YourDomain.com-error_log" CustomLog "/var/log/apache2/https_YourDomain.com-access_log" common SSLEngine On SSLCertificateFile /etc/apache2/*cert.pem SSLCertificateKeyFile /etc/apache2/*key.pem JkMountCopy On JkMount /* ajp13 </VirtualHost>

  1. Add Listen 443 in /etc/httpd/httpd.conf file, just add this line under Listen 80 you find at beginning of it.

Now you can access both http and https

Ghayel
  • 1,113
  • 2
  • 10
  • 19
  • All of your suggestions are already active in my configuration (my ...lots of other stuff... comment). The problem appears to be that mod_jk was working when the DocumentRoot was set to /opt/appserver/webapps/ROOT, but when I use an Alias instead it stops working (possibly, I'm running out of ideas). – Brian Jan 28 '16 at 19:13
  • have you set virtual hosts in your server.xml file? – Ghayel Jan 29 '16 at 17:16
0

This turned out to be an Apache Alias problem. Actually I couldn't get mod_jk to work with an Apache Alias, so I placed the Tomcat content in the Apache DirectoryRoot (the original config but with ssl turned on) and used:

SetEnvIf Request_URI "/content/*" no-jk
Alias /content /path/to/content

to enable the non-Tomcat content. Readers should also check (if they're using this technique) that they have added 'RewriteBase /content' to their .htaccess file.

Brian
  • 83
  • 1
  • 7