在ssl VirtualHost中设置Apache mod_jk

时间:2016-01-27 10:32:34

标签: apache mod-jk

我在将我的Apache mod_jk配置从其自己的VirtualHost配置移动到我的主要ssl VirtualHost配置时遇到问题。

Tomcat使用自己的域使用mod_jk和VirtualHost配置工作正常 - 工作配置....

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>

但是因为我想在我的主服务器页面中嵌入我的Tomcat表单,这些页面是ssl(不能混合http和https)我需要将我的mod_jk配置作为子文件夹移动到我的主ssl VirtualHost中。我尝试了以下更改,但在尝试访问https时遇到Tomcat错误'HTTP Status 404 - / servlet /'

新服务器配置:

<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>

2 个答案:

答案 0 :(得分:0)

  1. 确保您的域证书准确生成
  2. 在/ etc / apache2 /目录中复制* key.pem和* cert.pem
  3. 写下以下内容
  4. <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. 在/etc/httpd/httpd.conf文件中添加Listen 443,只需在开头找到的Listen 80下添加此行。
    2. 现在您可以访问http和https

答案 1 :(得分:0)

这结果是一个Apache Alias问题。实际上我无法让mod_jk使用Apache Alias,所以我将Tomcat内容放在Apache DirectoryRoot中(原始配置但启用了ssl)并使用:

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

启用非Tomcat内容。读者还应检查(如果他们使用此技术)他们已将“RewriteBase / content”添加到他们的.htaccess文件中。