Link to home
Start Free TrialLog in
Avatar of bhomass
bhomass

asked on

redirect with mod_jk

I want to redirect a http get for http://mysite:8080/myapp to
http://mysite/prefix_myapp

how do I specify a mod_jk command to do that?
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

first question which web server do you use on port 8080? Is it Apache httpd  server or Tomcat server ?
If it is Apache httpd then mod_rewrite can help you to do redirections.
If you use Tomcat server then you can try analog of mod_rewrite for tomcat http://www.tuckey.org/urlrewrite/
Avatar of bhomass
bhomass

ASKER

apache is listening to port 80. tomcat is on port 8080.

what should I do in this case?

There are at several options, depending on whether your Tomcat is listening for HTTP or AJP requests, and whether the links served by the tomcat are relative or absolute, anyway I'd suggest you have a look at the following articles:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#examples
http://www.apachetutor.org/admin/reverseproxies
http://confluence.atlassian.com/display/DOC/Using+Apache+with+mod_proxy#UsingApachewithmod_proxy-Configuremodproxy
http://wiki.zimbra.com/wiki/Zimbra_with_Apache_using_mod_jk_-_mod_proxy_-_mod_proxy_ajp

and then start by adding a mod_proxy_http block to your httpd.conf, before restarting the Apache e.g.

#Change /xxxxx/yyyy/ to match the other module load paths.
LoadModule proxy_module        /xxxxx/yyyy/modules/mod_proxy.so
LoadModule proxy_http_module /xxxxx/yyyy/modules/mod_proxy_http.so

<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>

ProxyRequests Off
ProxyPass            /prefix_myapp                    http://mysite:8080/myapp
ProxyPassReverse /prefix_myapp                    http://mysite:8080/myapp
# Following line may be needed to resolve absolute links / includes in Tomcat served content
ProxyHTMLURLMap http://mysite:8080/myapp  /prefix_myapp

Avatar of bhomass

ASKER

before I get too far reading the recommended articles, it seems they are all for mod_proxy not mod_jk. I am tied to mod_jk because that is what my isp provides. do these articles still apply?
Depends, have you configured your Tomcat to Listen for AJP traffic instead of HTTP, on port 8080? If not you'll need to use mod_proxy, and even if you have made the Tomcat server.xml change you can still use mod_proxy[_ajp] instead of mod_jk.

If you want to go down the mod_jk route, see either the last article above, or the Apache Tomcat site, as both provide examples.

Avatar of bhomass

ASKER

I know tomcat is listening to ajp. I have the following mod_jk setting

JkMount /rts/* ajp13

and it works. But I don't see any instructions in the referenced documents how the above setting works.

I can copy setting this time, because in addition to changing the port, I want to add a prefix to the servlet context name.

any suggestions?
Like readme file attached to your mod_jk download....
Avatar of bhomass

ASKER

can some one simply give me the settings for directing

http://mysite.com/mycontext to http://mysite.com:8080/prefix_mycontext
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bhomass

ASKER

do you mean to say
worker.my-worker.port=8080

otherwise where is the translation to port 8080?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bhomass

ASKER

do you the directives for setting the apache proxypass?
Avatar of bhomass

ASKER

I just saw arober11's input. I will try them out.
proxypass :8080 and jkmount :8009 are different worlds.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have both working in same apache - JK for 3 tomcat instances and proxypass with cache for 2 extremely slow embedded webservers.
Avatar of bhomass

ASKER

sorry, I am really raw on this configuration stuff. the interface provided to me by my isp says this

Apache is configured by placing directives in plain text configuration files. The main configuration file is usually called httpd.conf.
On this screen you can add custom directives into the <VirtualHost> sections of the Apache configuration file.To add directives, click the Edit button.

I don't have access to create *.properties file easily.

can I achieve the same without using any *.properties file? only using this interface to modify the apache config file?

I want to at least get the port forwarding to work, if without attaching the prefix.
.properties is mod_jk configuration

you cannot run mod_jk without configuration.

others proposed to go without mod_jk, which is apache-only solution.
Avatar of bhomass

ASKER

thanks for the instructions. they look good. I will try them later, because they do not look easy to implement.
Avatar of bhomass

ASKER

good and thorough answers