I set up apache on 4 ports (with virtual hosts as some ports used HTTPS) and also the goal would be to redirect publish demands to various servlets running inside a TOMCAT instance on another machine. The calls are manufactured from a httpclient (java client) . After I run the customer it throws the mistake 301 Error: Moved Permanently. Need hints/tips/help regarding how to solve the this issue.

It might be nice if a person can provide us a example. My virtual host (using the re-direction) appears like something similar to this

VirtualHost default:3334>
RewriteEngine On
RewriteRule ^/$

I'm now capable of getting mod proxy dealing with mod rewrite and today I dont obtain the 302 error, but because it always transpires with a new there's this one other issue.

HTTP Publish demands aren't working. After I problem the publish request, the proxy fails because it continues to search for index.htm.

My httpd.conf snippet

VirtualHost *:3331>
ServerName localhost:3331
ProxyPass /
ProxyPassReverse /
RewriteEngine on
RewriteRule ^/$ http://localhost:3331/

A 301 seems like the right response if you want to redirect, but you may wanted to proxy the demands to ensure that the customer was not aware from the redirect? Within this situation, have a look at using mod_proxy like a reverse proxy.

An alternative choice additional towards the already given mod _ proxy is mod _ jk. (sorry for that spaces, otherwise formatting is screwed up)

Both of them are apache extensions that permit apache to eat the request, transparently forward it to tomcat, wait for a response after which send the end result back.

IMHO mod_jk includes a couple of advantages

  • Tomcat automagically will get the offered hostname, protocol and port (with mod_proxy you need to configure the truth that it's proxied within the Connector, begin to see the options proxyName and proxyPort
  • mod_jk provides loadbalancing - in the event you need this
  • apache talks to tomcat inside a protocol created for this (ajp13). With mod_proxy they talk http, with a slightly greater overhead (Disclosure: I have never measured it myself, just parrotting it)

That which you use ultimately is totally your decision - it isn't that much a noticeable difference between both options. (Someone correct me if it's)

Configuration is the following (untested pseudocode. Do browse the paperwork, please know very well what you need to do...)

# somewhere in httpd.conf, above the virtual hosts
JkWorkersFile /etc/apache2/workers.properties
JkLogFile     /var/log/apache/mod_jk.log
JkLogLevel    error

# your existing part with virtual hosts
<VirtualHost ...>
   JkMount /Lang/* tomcat1
   JkMount /Lang   tomcat1  # if you need the directory itself also to be forwarded

# the workers.properties file described above
# 'tomcat1' is the reference used above as argument to JkMount

Your httpclient in java must correctly handle 301 solutions. If it doesn't, it's damaged. If you do not want or can't, then using mod_rewrite/mod_proxy as shown by Paul to "transparently" redirect is what you want. See here

Accomplished this using JK and mod rewrite. The issue was with two-way SSL and that i set up the ports to operate along with 443 (SSL) port.


Note: if a person expects to rewrite URL's within the virtual hosts then JK mount needs to be reloaded for every virtual host.

My URL rewrites seem like this

RewriteEngine on
RewriteCond % 4342
RewriteRule ^/$ /Lang/Englangservices/Alapbhet_service [L,PT]

Thanks everybody one for his or her inputs.