Am 17.10.2016 um 19:16 schrieb Marc Chamberlin:
Hello -  My apologies if this has already been asked or the wrong mail
list, but Google is not coming up with an answer for me, so here goes...

I am trying to set up the mod_jk connector between an Apache HTTPD
server and Tomcat with the intent of supporting virtual hosts, and
serving static content from the Apache server and forwarding jsp and
servlet requests to Tomcat. Typical scenario I know...

Most of this I have working but the trouble I am having is with the use
an Alias directive for the Apache server. Following instructions for the
JSP examples that came with my distribution for Tomcat 8, I created a
configuration for

 <IfModule mod_jk.c>

  # The following line makes apache aware of the location of
  # the /jsp-examples context
  Alias /jsp-examples "/srv/tomcat/webapps/examples/jsp"

  <Directory "/srv/tomcat/webapps/examples/jsp">
        Options Indexes  FollowSymLinks
        AllowOverride None
    # Controls who can get stuff from this server.
    <IfModule !mod_access_compat.c>
            Require all granted
    </IfModule>
    <IfModule mod_access_compat.c>
        Order allow,deny
        Allow from all
    </IfModule>
  </Directory>

  # Mounted stuff goes via tomcat (ajp13)
  JkMount /jsp-examples tomcatWorker1
  JkMount /jsp-examples/* tomcatWorker1
  # Serve html, css, js, jpg, png and gif using Apache
  JkUnMount /*.html tomcatWorker1
  JkUnMount /*.css tomcatWorker1
  JkUnMount /*.js tomcatWorker1
  JkUnMount /*.jpg  tomcatWorker1
  JkUnMount /*.png  tomcatWorker1
  JkUnMount /*.gif  tomcatWorker1
</IfModule>

I am actually defining this in the context of a virtual host and if
necessary I can post its configuration as well.

Using the JK debug level and monitoring the mod_jk.log file I can see
what is going wrong, I just don't know how to rectify it -

[Mon Oct 17 09:28:01.145 2016] [30237:139868423546816] [debug]
ajp_connection_tcp_send_message::jk_ajp_common.c (1208): sending to
ajp13 pos=4 len=469 max=8192
[Mon Oct 17 09:28:01.145 2016] [30237:139868423546816] [debug]
ajp_connection_tcp_send_message::jk_ajp_common.c (1208): 0000 12 34 01
D1 02 02 00 08 48 54 54 50 2F 31 2E 31  - .4......HTTP/1.1
[Mon Oct 17 09:28:01.145 2016] [30237:139868423546816] [debug]
ajp_connection_tcp_send_message::jk_ajp_common.c (1208): 0010 00 00 0E
2F 6A 73 70 2D 65 78 61 6D 70 6C 65 73  - .../jsp-examples
[Mon Oct 17 09:28:01.145 2016] [30237:139868423546816] [debug]
ajp_connection_tcp_send_message::jk_ajp_common.c (1208): 0020 2F 00 00
0D 31 39 32 2E 31 36 38 2E 31 30 2E 31  - /...192.168.10.1

This excerpt shows that the Apache server is sending a message to the
Tomcat worker telling it to find a resource "/jsp-examples" which of
course doesn't really exist and so Tomcat reports a "Not Found" failure.
What I want is for the Apache server to send the actual location that
this alias is mapped to i.e. "/examples/jsp", which is what actually
exists in the Tomcat context. I can fool Tomcat into handling this alias
request by creating a link named jsp-examples -> examples/jsp within the
Tomcat webapps directory but that seems like a hack and not something I
want to have to do/maintain for all the other resources I will want to
handle via alias commands.

Is there a magic incantation that I am missing?  Thanks in advance for
suggestions/help....     Marc...

Alias maps URIs to local file system directories.
JkMount maps URIs to remote back end requests.

You can not change JkMount forwarding using Alias (except that if you have a comflict between Alias and JkMount only one of them wins).

As far as I understand you are not really trying to map requests to the local web server file system, but instead want to forward to a Tomcat back end but change the URI path which is used when accessing Apache to something else being used to acces Tomcat. E.g. the URI /jsp-examples/something gets used when accessing Apache and mod_jk should send this request as /examples/jsp/something to the Tomcat back end.

If you really need to change URIs, then often mod_proxy is much easier to set up, because it has specific directives for this (ProxyPass etc.).

With mod_jk you would first need to use mod_rewrite RewriteRules to change the URI, and then JkMount to forward them. More details can be found at

http://tomcat.apache.org/connectors-doc/common_howto/proxy.html#URL%20Rewriting

The rest of this docs page might be useful as well.

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to