• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirection rules for Apache Web Server\Tomcat 7

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to set up a redirect that does this...

On the Tomcat server, running on port 8080 I have an application with this url http://localhost:8080/MyApp
Port 8080 is blocked from the outside
Apache Web Server is on port 80 and services public requests for Tomcat.

And on the public Internet, a user types in..
http://www.publicwhatevermywebsite.com

It then redirects to the application. But in the browser url it says
http://www.publicwhatevermywebsite.com/MyApp

I want it to say
http://publicwhatevermywebsite.com without the /MyApp part.

I researched the httpd-vhost.xml file in the web server, but to no avail.



 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to adapt Tomcat's server.xml file. You probably need something like this:

 
M Burke
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You need to adapt Tomcat's server.xml file. You probably need something like this:



I am getting 'Page not found'. There is already a <host> tag for localhost. Do I need to combine them some how?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, and adapt the "appBase" attribute to your circumstances.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if you need this, the Tomcat mod_jk module should be installed too. Then the Tomcat server need to add some config (exactly what I can't recall).

Then in apache server make a conf file having the line:



Then in the apache httpd.conf add the line at the bottom:



Then restart tomcat and apache.

I have done this redirection thing for Glassfish app server so Tomcat should be similar.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 ways to solve this common problem when you have Apache HTTPD + Apache Tomcat. Both involve using Apache HTTPD as a proxy server for Tomcat.

The Apache mod_jk module is the traditional way to do this. It establishes a tunnel from Apache HTTPD to Tomcat via Tomcat's proxy port (8009). You provide proxy configuration in the Apache configuration file(s) that includes the external URL pattern and the Tomcat URL translation of that pattern. The Tomcat server also has worker directives to assist in the process.

The Apache mod_proxy module is the newer and preferred way to do this. It works much like mod_jk, except that it's simpler to configure and you don't have to make any configuration changes on the Tomcat side. However, mod_proxy should be used with care. If you set up a reverse proxy as an open proxy (which isn't hard to do), a whole army of nasty people based on Taiwan's HINET ISP service will show up like flies around a dead animal and within 2-3 days, your system will be so busy operating as a spam relay that it won't be usable for anything else.

I'm picking on HINET specifically since they're atrociously notable offenders to the point where my network has banned thousands of HINET IP addresses, but actually would-be spammers anywhere in the world can - and will - do the same.
 
reply
    Bookmark Topic Watch Topic
  • New Topic