Redirect help

I'm having a problem getting apache 2.x to properly redirect a url request. Heres the background.

I have OS X server running two web servers, the primary server is the included apache 2.x supplied with the OS X server software running on the default port 80. The second is a CMS that runs on port 8080.

There are 5 web site that apache is hosting and two that the CMS takes care of. I wish to have Apache handle all of the web requests so that to the outside user all urls seem to be standard with no port identities showing. to do this I have added two additional sites to Apache that I want to use the redirect capabilities to change the URL seen be the end user, as well as redirect the request to the correct server.

Example:

User requests http://www.example.com

I would like apache to see the above pattern, and redirect it to:
http://www.example.com:8080/dir1/dir2/

And I would like the resulting URL to be shown in the users browser as:
http://www.example.com

I have to admit I have not used the redirect capabilits very much, and am reading the apache.org site for info on mod_rewrite and trying to apply that to OS X server via the GUI for the web server.

Any help?

Tom

Lots of Macs, Mac OS X (10.5.4)

Posted on Aug 13, 2008 1:50 PM

Reply
9 replies

Aug 13, 2008 2:27 PM in response to Tom Nelson1

First of all you don't want a redirect at all.

A redirect is a command sent back to the client saying "the content you asked for is really over here...". That's not what you want.

What you want is for Apache to proxy the connection - silently (to the user) forward the request to the destination server, and pass the results back to the client.

This kind of setup cannot be done via Server Admin, so you're going to have to get under the hood and edit the site's .conf file directly.

Fortunately that's pretty easy (I can show you what to add), but I think you're missing some details in your original post.

You're saying you want 'http://www.example.com/" to be proxied to http://www.example.com:8080/dir1/dir2/ right?

What about any other URL on www.example.com? The above will work for that one page, and that one page only. What about http://www.example.com/otherpage.html ? Do you want that to serve otherpage.html from the main site, or proxy http://www.example.com:8080/dir1/dir2/otherpage.html ?

Does the CMS use forms and parameters? If so, that's another consideration (proxying any request to http://www.example.com/dir1/dir2/ would, by definition, drop any form parameters. I'm guessing that's not what you want.

So if you can flesh out what it is you really want, I can point you in the right direction.

Aug 13, 2008 2:46 PM in response to Camelot

Hi Camelot,

Thanks for the response.

To help flesh this out a bit the http://www.example.com:8080/dir1/dir2/ can be though of as the base directory for all pages that would be served by the CMS, So you are correct that http://www.example.com/otherpage.html, should be served up from http://www.example.com:8080/dir1/dir2/otherpage.html.

As far as passing any form parameters, It doesn't appear the CMS (zope/plone) passes anything via the url. And all content creation and editing will be performed from the internal network with direct access to the cumbersome plone server and its unwielding urls. External viewers of the site will only see the pages plone generates without any editing capabilities. So the only thing that may be embedded in the URL will be when a search is performed which will generate urls like /search?SearchableText=something.

thanks for your assistance.

Tom

Aug 13, 2008 2:53 PM in response to RedRhubarb

Alias won't do the job I think, since they are if I understand correctly only used to alias paths on the same web server.

I actually use aliases to lock out management paths from the internet facing side of the web server. Those paths also have other security, but that is a simple way to force anyone externally from being able to easily access management interface.

Tom

Aug 13, 2008 7:03 PM in response to RedRhubarb

Hi,
As I understand your question, I think there is some confusing information provided here and the solution is not difficult to achieve. You have more than one web server and wish Apache to direct traffic. Neither redirect nor alias is appropriate if you want your client to see only one url domain without port numbers. The solution is a reverse proxy and server admin gui is very capable to set this up. It also does not result in loss of data or form parameter information.
For a simple explanation of reverse proxy take a look at http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzaie/rza ieproxytypes.htm

For a site setup in Web services (www.example.com), select proxy panel,
check Enable Reverse Proxy, put a single slash in Proxy Path
add a balancer member with worker url 127.0.0.1:8080/dir1/dir2/ with 100percent load factor.
Leave sticky session identifier blank.
* Ensure NO sites on your server have an asterisk in the alias panel *
Restart web service.

You will be accepting all traffic for the site (www.example.com) (the single slash in Proxy Path) and directing it to the server running on the local machine listening on port 8080 with root folder/dir1/dir2/ No forms information or get or post request data will be changed or dropped.
Your client will only see the url www.example.com
If the second server is not on the local machine then use its internal IP address instead of 127.0.0.1. If the root folder changes then specify the change in the worker url.

HTH,
Harry

Aug 14, 2008 8:56 PM in response to Tom Nelson1

Just to let anyone interested know...

The method I finally ended up using was to to use Apaches mod_rewrite to rewrite the url and access the application server running on port 8080. I did need to edit the virtual_host.conf file that Apple uses for Apache virtual hosts. Here is an example take from my working file. Remember this is specific to using zope/plone and you will see some funny names in the path names for the rewrite rule, these names are specific to zope/plone.

RewriteRule ^(.*) http://localhost:8080/VirtualHostBase/http/www.example.com:80/dir1/dir2/VirtualH ostRoot/$1 [L,P]

Trying to do this by using reverse proxy was not affective and would result in only the first requested page being properly delivered. All links embedded in page delivered would be rewritten by the reverse proxy such that they pointed directly to the localhost server, which of course would then fail if a user ever clicked on them. This seems to be an issue with zope/plone and Apache2 reverse proxy only and not the reverse proxy by itself.

I suppose the rewrite rule could have been written with the following match pattern instead:

RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.example.com:80/dir1/dir2/VirtualH ostRoot/$1 [L,P]

But I don't see it making to much of a difference.

Tom

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Redirect help

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.