0

I have a tomcat(running on 8080) application on my cent os server and i can access it with the url:

SERVER_IP:8080/myapp

and I have my admin panel on

SERVER_IP:8080/myapp/admin

and I have an apache server running on port 80.

I have two domains :

www.myapp.com
admin.myapp.com

I've managed to configure tomcat, mod_jk and apache server such that admin.myapp.com url opens the tomcat home page(SERVER_IP:8080).

But what I want is to make admin.myapp.com url to open SERVER_IP:8080/myapp/admin and www.myapp.com to open SERVER_IP:8080/myapp.

I need to make apache know when a request came to admin.myapp.com, it should know to redirect the request to SERVER_IP:8080/myapp/admin. Something is missing obviously.

Here are my configurations :

httpd.conf (admin.myapp.com.conf actually because it is created by plesk panel but i think it's irrevelant)

<VirtualHost SERVER_IP:80 >
    ServerName "admin.myapp.com:80"
    ServerAlias "www.admin.myapp.com"
    ServerAlias "ipv4.admin.myapp.co"
    ServerAdmin "cuneyty@mycompany.com"
    UseCanonicalName Off

    JkMount / ajp13
    JkMount /* ajp13

    ....
</VirtualHost>

mod_jk.conf

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
# Update this path to match your conf directory location
JkWorkersFile /usr/local/tomcat7/conf/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location
JkLogFile /usr/local/tomcat7/logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel debug

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

workers.properties

# Define 1 real worker named ajp13
worker.list=ajp13

# Set properties for worker named ajp13 to use ajp13 protocol,
# and run on port 8009
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=8009
worker.ajp13.lbfactor=50
worker.ajp13.cachesize=10
worker.ajp13.cache_timeout=600
worker.ajp13.socket_keepalive=1
worker.ajp13.socket_timeout=300

Thanks in advance.

closed as off-topic by HopelessN00b Feb 24 '15 at 3:54

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I don't think you can change the path part of the URL with mod_jk. If you want to use mod_jk, you'd need to rewrite the URL first so that the path part of the URL matches the expected path on the backend. Other option is use mod_proxy, as you found out. It's more flexible in this area. – Daniel Mikusa Dec 22 '14 at 16:45
  • Administration panels are off topic. – HopelessN00b Feb 24 '15 at 3:54
2

I've figured that out using mod_proxy instead of mod_jk and adding these lines :

ProxyPass / http:// SERVER_IP:8080/ 
ProxyPass /myapp/ http:// SERVER_IP:8080/myapp

And this line for cookies :

ProxyPassReverseCookiePath /myapp /"

Not the answer you're looking for? Browse other questions tagged or ask your own question.