Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ProxyPass from httpd to tomcat

 
Sub Gowda
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not sure if this is the correct forum to request help, but I could not find a better place. I am trying to setup an httpd server in front of tomcat on centos 5.8.
In the httpd.conf file I have written the below

ProxyRequests off
ProxyPreserveHost on
ProxyPass /static.htm !
ProxyPass / http://localhost:8082/
ProxyPassReverse / http://localhost:8082/


This works fine if I have only 1 static page. I have a little over 34 static pages. Could you please help me figure out how to have multiple static pages serviced by httpd and others go to tomcat?

http://localhost/static1.html ==> static page 1
http://localhost/static2.html ==> static page 2

http://localhost/ ==> should goto tomcat's webapp

Thanks,
Sub
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered putting all the static content in one directory and exempting that directory from proxying?

Incidentally, if you are attempting to use http to serve static pages instead of Tomcat merely because "it's more efficient", that hasn't been true for about a decade now.
 
Sub Gowda
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply. I am trying your suggestion and use tomcat to serve my static content also. I still get to see the folder name in the URL where my static pages are stored.

I have multiple directories and static pages inside "myfolder" and I dont want to display "myfolder" in the url. I am ok with displaying the directory names.

example:http://localhost/myfolder/sub/index.html works, but I want it to show as http://localhost/sub/index.html and
http://localhost/myfolder/static1.html works. but i want the url to look like http://localhost/static1.html


Could you please help me out?

Thanks,
Sub
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly, you want resources from 2 different sources (apache and Tomcat) to appear as though they were all coming from one source in the URL path.

You can't do that, because someone (Apache, since it gets the first shot) has to have some sort of clue as to which kind of resource it's retrieving in order to know where to get it from. That cue usually would be done as a "directory" in the URL - for example "/images", "/scripts" and "/styles", but an Apache rewrite could also trigger on magic patterns in the resource name (for example, "*.jpg).
 
Sub Gowda
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I have removed Apache from my system. I have only tomcat 7 on port 80. I followed your suggestion on the earlier post and decided to use only tomcat for both dynamic and static content.

I am still having the same issue as earlier. I want the below to work. Please help..

http://localhost/myfolder/sub/index.html works, but I want it to show as http://localhost/sub/index.html and
http://localhost/myfolder/static1.html works. but i want the url to look like http://localhost/static1.html
 
K. Gil
Ranch Hand
Posts: 75
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat's default app is inside webapps/ROOT
so follow this:
1) take a backup of all your webapps directory
2) remove webapps/ROOT
3) change name of "myfolder" to "ROOT"
4) restart tomcat
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More correctly, Tomcat's default webapp is webapps/ROOT.
 
K. Gil
Ranch Hand
Posts: 75
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More correctly, Tomcat's default webapp is webapps/ROOT.


Thank you for correction
 
Sub Gowda
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I did that. I backed up ROOT folder and then renamed my application.war file to ROOT.war and tomcat deployed it as ROOT. I can see my web application on http://localhost
But i still cannot see my static pages. My static pages are in /usr/share/website/, which is not my in webapps directory(/usr/local/tomcat7/webapps/). My application creates a lot of static (html) pages and is saved in /usr/share/website/. This location is Alias to myfolder in my web application.

example: when some one uses my web application, a new folder with html pages are created and saved in /usr/share/website (myfolder). Lets say the new folder is called "sub".

Now when i point my browser to http://localhost/myfolder/sub/index.html i can see the content of index.html, but
I want the browser to show me the content of index.html, when i use http://localhost/sub/index.html (as of now i see a 404 error)

Basically, I don't want the users to see the word "myfolder" in the URL.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using filesystem aliases (links), you may need to override Tomcat's default settings. For security reasons, I don't believe that Tomcat will resolve through aliases unless explicitly instructed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic