【问题标题】:How to configure apache2 and Tomcat8 with mod_jk?如何使用 mod_jk 配置 apache2 和 Tomcat8?
【发布时间】:2018-07-10 20:57:35
【问题描述】:

我的 apache2 和 tomcat8 配置有些问题。

<Virtualhost example.com>
JkMount /* ajp13_worker
ServerName example.com
DocumentRoot /opt/tomcat/public/my-webapp
ErrorLog /opt/tomcat/logs/error.log
CustomLog /opt/tomcat/logs/access.log common
<Directory /opt/tomcat/public/my-webapp>
    Options -Indexes
</Directory>

这个工作正常,因此来自 example.com 的每个请求都映射到 tomcat。

在同一台服务器上运行一个 kolab 邮件服务器,如果我尝试使用 example.com/anypath 登录到 example.com/roundcubemail 或其他 Web 服务,那么也会映射到我的 tomcat,这很糟糕。

如何配置排除 example.com/anypath 的 apache2?

这是我的 example.com/roundcubemail 的虚拟主机,它不起作用:

<VirtualHost *:80>
Alias /roundcubemail /usr/share/roundcubemail/public_html/

别名 /webmail /usr/share/roundcubemail/public_html/

SetEnv 无 gzip 过期活动在 ExpiresDefault "访问加 1 个月"

选项 +FollowSymLinks AllowOverride None

# php garbage collection for file-based sessions on debian is done via
# cronjob but roundcubemail uses mysql as storage during runtime which is
# not cleaned up by the cronjob. So reenable the default php gc method
php_admin_value session.gc_probability 1

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/(roundcubemail|webmail)
    RewriteRule ^[a-zA-Z0-9]{16}/(.*) /%1/$1 [PT,L]
</ifModule>
<ifModule mod_authz_core.c>
    Require all granted
</ifModule>
<ifModule !mod_authz_core.c>
    Order Allow,Deny
    Allow from All
</ifModule>

thx 4 帮助 :)

【问题讨论】:

    标签: tomcat apache2 tomcat8 mod-jk kolab


    【解决方案1】:

    如果您只想排除 /roudncubemail 使用 mod_jk 映射到 Tomcat 的上下文路径,您可以使用 JkUnmount 排除它:

    JkUnmount /roundcubemail ajp13_worker
    JkUnmount /roundcubemail/* ajp13_worker
    

    这样,你的虚拟主机配置应该是这样的:

    <Virtualhost example.com>
    JkMount /* ajp13_worker
    JkUnmount /roundcubemail ajp13_worker
    JkUnmount /roundcubemail/* ajp13_worker
    ServerName example.com
    DocumentRoot /opt/tomcat/public/my-webapp
    ErrorLog /opt/tomcat/logs/error.log
    CustomLog /opt/tomcat/logs/access.log common
    <Directory /opt/tomcat/public/my-webapp>
        Options -Indexes
    </Directory>
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-26
      • 2015-03-30
      相关资源
      最近更新 更多