aspose file tools*
The moose likes Tomcat and the fly likes any experience out there with mod_proxy_html or other uri modification methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "any experience out there with mod_proxy_html or other uri modification methods?" Watch "any experience out there with mod_proxy_html or other uri modification methods?" New topic
Author

any experience out there with mod_proxy_html or other uri modification methods?

Derek Murphy
Greenhorn

Joined: Mar 26, 2010
Posts: 25
Hi again,
Feel like a regular now

I need to change my URLs on the fly and insert a string into them. Reason being is I have an application that is poorly designed and I need to configure my load balancer to send traffic to the appserver(tomcat) using a single string /blah/

original url www.domain.com/fancyurl -> one time rewrite to old(should be new) url below.

so... old url = www.domain.com/web/appname/*
new url = www.domain.com/blah/web/appname/*

I've heard mod_proxy_html can do this for me but I have been banging my head for hours trying to get it to work.

Essentially I need the URL for the user to always be www.domain.com/blah/web/appname/* but once it leaves the load balancer, apache needs to strip out the /blah/ for the application to function properly. Once apache is ready to return data to the end user, it needs to add /blah/ back into the URI so the user (and load balancer) always think they are on www.domain.com/blah/web/appname/*

The /web/ piece actually can vary too. It can be /web/ or /group/

This is proving to be quite a difficult task and I'm starting to lose my hair...

Any help, most appreciated!!!
Derek Murphy
Greenhorn

Joined: Mar 26, 2010
Posts: 25
now that I think about it a bit more, I don't think that even mod_proxy_html will help out in this particular case.

The big issue that I face isn't necessarily with the url's the end user sees... but rather the way things are linked within the application. There's a lot of root/relative linking.. so I have things like src=customapp1/images/something.jpg and src=customapp2/images/something2.png and src=customapp3/js/somefunction.js

anyways... on and on we go, for about 60 custom apps, as well as other root level references.

The real solution is to deploy it outside of a context root so I can change the app to be www.domain.com/nonRootContext/application... but the application doesn't support it.. due to the way things are linked...

so essentially, what I really need is something that can modify all of the html that gets passed through the browser/server and have all links(relative and hardcoded) to get some sort of constant prefixed in there.

My gut feeling is that, it's impossible, and I'm going to have to setup a subhost (app.domain.com) instead of being able to use our single namespace www.domain.com/app for authentication etc...

I'm starting to feel pressure, so all geniuses come out of the woodwork

Cheers.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Sounds more like a job for mod_rewrite.

You make it sound like there's probably going to be dozens of rewrite rules required. Hopefully not, though. Usually - but not always - relative URLs can be more flexible than absolute URLs.

Customer surveys are for companies who didn't pay proper attention to begin with.
Derek Murphy
Greenhorn

Joined: Mar 26, 2010
Posts: 25
well actually wouldn't mod_rewrite not be able to help in that case? Mod_rewrite is only for url manipulation, not for internal code path manipulation I thought?

I looked into mod_proxy_html further... and it appears that it can do what I want it to do... I just don't know how to use it

the things that need changing are the actual html tags in the code.. so src=/customapp1/images/image.png needs to be changed(in the code) to reflect src-/insertedstring/customapp1/images/image.png

but only for the end user to see. It will be stripped back out once the request goes back to the application so it functions properly.

I threw in the towel yesterday and now I'm going to take the approach of a new namespace.

So, instead of www.domain.com/app1, I'm just creating app1.domain.com and writing a load balancer rule that says if host = app1.domain.com then send everything to appservers.

Not ideal... but at least it'll save my hair from all falling out
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Well it's too late to save my hair (which is why my ranch photo has me wearing a hat to prevent camera glare ).

But I'm running sites that combine mod_proxy with mod_rewrite to do stuff like that. The outgoing URLs might be a bit sticky, though. If you want them bookmarkable under abstract URLs, you may have to format them when you generate the pages.
Derek Murphy
Greenhorn

Joined: Mar 26, 2010
Posts: 25
Interesting...

See... I honestly believe it's possible to do what I'm trying to do. I just don't know how all the pieces work together/should be configured

I'm not concerned with things being bookmarkable. These are all for POC environments so end users never bookmark anything except a main url.

Once I actually get it rolled out I think I'm going to revisit this. I KNOW it can be done and it's going to irk me forever if I can't get it working how I originally intended.

Thanks very much for the help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any experience out there with mod_proxy_html or other uri modification methods?