Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: URL rewrite, best way to implement routing logic ? |
|
Author |
|
laurent.landreau
Joined: 12 Jun 2014 Posts: 2 Location: Sydney, Australia
|
Posted: Thu 12 Jun '14 12:38 Post subject: URL rewrite, best way to implement routing logic ? |
|
|
Hello,
I have a configuration issue, that I am sure other people have resolved.
I have the following setup:
* two Apache web servers, that provide static content from their file system,
* two Load Balancers, that convert the port 80 to 8080 before routing the requests to Java application servers,
* a series of Java application servers, listening on port 8080.
I have done the following:
1) Apache to serve static content from the web server,
2) Apache to route all URLs suffixed with (/lportal) to the load balancer and then to the app server. To do so, I have updated httpd.conf with the proxy command. That works.
My problem:
* When the page gets handed back from the app servers to the browser, it contains links that do not have the /lportal suffix. Meaning when the user clicks on these links, Apache tries to serve the content from Apache ... and it fails if that is to be handled by the app server.
My question is what is best way to implement that routing logic:
1) in Apache, can I rewrite the URL contained in the HTML for the outbound traffic sent to the browser (basically to add /lportal in all URLs)?
2) alternatively, can I do the opposite, that is to route all requests to the App servers, except URLs having a certain pattern corresponding to static content to be served by Apache?
3) Any other option?
To me option 2) would seem easier as I master the content structure stored on Apache (and not really the URL structure of the app on the app servers).
But what would I need to do it via an httpd.conf change?
Thanks,
Laurent LANDREAU
Sydney, Australia |
|
Back to top |
|
Anaksunaman
Joined: 19 Dec 2013 Posts: 54
|
Posted: Sat 14 Jun '14 4:47 Post subject: URL rewrite |
|
|
Quote: | My question is what is best way to implement that routing logic:
1) in Apache, can I rewrite the URL contained in the HTML for the outbound traffic sent to the browser (basically to add /lportal in all URLs)?
2) alternatively, can I do the opposite, that is to route all requests to the App servers, except URLs having a certain pattern corresponding to static content to be served by Apache?
3) Any other option? |
1.) Some combination of mod_proxy_html, mod_substitute and/or mod_sed would likely do the trick.
2.) You may want to investigate mod_rewrite. This page
http://corz.org/server/tricks/htaccess2.php?page=1
is aimed more at rewrite rules in .htaccess files, but those same rules can be used in virtual hosts, etc. |
|
Back to top |
|
|
|
|
|
|