logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: Problem with mod_jk.so
Author
doyledp



Joined: 20 Jul 2006
Posts: 3

PostPosted: Thu 20 Jul '06 18:25    Post subject: Problem with mod_jk.so Reply with quote

Hi.

I have just set up a new configuration

Windows XP SP2
Apache 2.2.2
PHP 5.2.0-dev
Apache Tomcat 5.5.17

I am new to configuring apache and tomcat. But I wan't to use the mod_jk approach to not having to use port numbers in requests for tomcat. In other words use:
http://localhost/jsp-examples/jsp2/el/basic-arithmetic.jsp
instead of
http://localhost:8080/jsp-examples/jsp2/el/basic-arithmetic.jsp
I got this working fine by:


    1. Adding mod_jk.so to C:\Program Files\Apache Software Foundation\Apache2.2\modules.

    2. Add the following to the end of Apache httpd.conf file.

    Include "C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\auto\mod_jk.conf"

    4. Add the following line to the server.xml file before “<Host name=”localhost” appBase=”webapps” in C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf.

    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>

    <Listener className="org.apache.jk.config.ApacheConfig" modJk="C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so" />

    5. Create a new text file called workers2.properties and paste the following into it. Save this file in the following directory:

    C:\Program Files\Apache Software Foundation\Apache2.2\conf
    [logger]
    level=DEBUG
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.log
    [config]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/conf/workers.properties
    debug=0
    debugEnv=0


    [shm]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.shm
    size=1048576

    # socket channel
    [channel.socket:localhost:8009]
    port=8009
    host=127.0.0.1

    # worker for the connector
    [ajp13:localhost:8009]
    channel=channel.socket:localhost:8009

    [status:status]

    [uri:/status/*]
    worker=status:status

    [uri:/jsp-examples/*]
    worker=ajp13:localhost:8009

    [uri:/*.jsp]
    worker=ajp13:localhost:8009


The problem occurs when I use a domain name. For example if I use
http://name.homeip.net/jsp-examples/jsp2/el/basic-arithmetic.jsp
I see the original jsp source, however if I use
http://name.homeip.net:8080/jsp-examples/jsp2/el/basic-arithmetic.jsp
It works fine.

I have tried loads of things including adding the following to my workers2.properties file.

[uri:donal.homeip.net/jsp-examples/*]
worker=ajp13:donal.homeip.net:8009

[uri:donal.homeip.net/*.jsp]
worker=ajp13:donal.homeip.net:8009

In case it might make a difference my computer is a home computer. And I am using dyndns to map the url donal.homeip.net to my ip address. The requests are being forwarded through a Linksys WRT54GS Router, by enabling port forwarding for ports 80 and 8080 to the internal ip of my pc.
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 682

PostPosted: Thu 20 Jul '06 18:31    Post subject: Reply with quote

Why not use mod_proxy_ajp http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html Question

Example:

ProxyPass /examples ajp://127.0.0.1:8009/examples
ProxyPassReverse /examples ajp://127.0.0.1:8009/examples

Steffen
Back to top
doyledp



Joined: 20 Jul 2006
Posts: 3

PostPosted: Thu 20 Jul '06 18:49    Post subject: Reply with quote

Thanks for the prompt reply.

I have enabled the mod_proxy_ajp by changing the line
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
to
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
in httpd.conf.

Can restart apache then.

Where would I add the following lines to my configuration

ProxyPass /jsp-examples ajp://127.0.0.1:8009/jsp-examples
ProxyPassReverse /jsp-examples ajp://127.0.0.1:8009/jsp-examples

If I add it to httpd.conf, apache can't restart
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 682

PostPosted: Thu 20 Jul '06 18:56    Post subject: Reply with quote

When you run Apache in a DOS box you can see the startup-errors.

Did you enable: LoadModule proxy_module modules/mod_proxy.so ?
Back to top
doyledp



Joined: 20 Jul 2006
Posts: 3

PostPosted: Thu 20 Jul '06 19:04    Post subject: Reply with quote

Got it working.

The problem was that I forget to enable LoadModule proxy_module modules/mod_proxy.so

Thanks a million for your help. Have been looking all over the web for hours. Was looking for the wrong things. Learnt a lot today.

Is there any security issues I should consider as a result of using the proxy method?
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 682

PostPosted: Thu 20 Jul '06 19:21    Post subject: Reply with quote

A million ? So much donation ? Smile

Be sure to set: ProxyRequests Off

Indeed using mod_jk can be a hassle. Mod_proxy_ajp is new in Apache 2.2 .

Steffen
Back to top
mphare



Joined: 12 May 2006
Posts: 43
Location: Texas

PostPosted: Thu 20 Jul '06 19:34    Post subject: Reply with quote

I'll have to check out mod_proxy_ajp.

I'm using Apache 2.2.2 with Tomcat 5.5.17 using mod_jk.

This is my addition to httpd.conf
Code:
<IfModule !mod_jk.c>
    LoadModule jk_module modules/mod_jk.so
    JkWorkersFile "C:/Programs/ApacheGroup/Apache2.2/conf/workers.properties"
    JkMount /jsp-examples/* worker1
    JkMount /servlets-examples/* worker1
    JkMount /axis2/* worker1
    JkMount /exist/* worker1
</IfModule>


Here is my workers.properties
Code:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.recycle_timeout=300


I don't believe I had to modify any other file (server.xml)

I haven't noticed any problems using domains.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Thu 20 Jul '06 19:44    Post subject: Reply with quote

would
Code:
<FilesMatch *jsp>
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
</FilesMatch>


Work aswel ? to only forward *.jsp files?
Back to top


Reply to topic   Topic: Problem with mod_jk.so View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules