Mod Rewrite Question
Posted by: Maudib (---.6197.cust.vallnet.com)
Date: December 17, 2006 09:34PM

I am using WAMP 1.6.6. with VirtualHosts to redirect inbound http traffic to a secondary application server on a different port number (using ProxyPass and ProxyPassReverse).

That part of things is all working fine.


I'd like to be able to use Mod Rewrite to grab the domain name from the inbound URLs and pass that to the secondary server as a parameter.

In example:

When this URL comes in...

[test.mydomain.com]

I want to be able to rewrite the URL as:

[test.mydomain.com]


Then the ProxyPass would send the modified URL to my secondary server where the ID= parameter would be used to tell the server which account it was servicing.

This would be much faster than parsing the domain out of the URL and it would be more accurate since the Mod directive would always set the correct ID.


I'm still getting my head around everything that can be done with Mod Rewrite, so any help our suggestions is appreciated.

Thanks!

M

Options: ReplyQuote
Re: Mod Rewrite Question
Posted by: steveryherd (---.central.biz.rr.com)
Date: December 17, 2006 09:50PM

I don't understand what exactly you're asking for...

It almost seems like Mod_Rewrite is the wrong path though?

Could you be more detailed on what you're looking to accomplish?

Options: ReplyQuote
Re: Mod Rewrite Question
Posted by: Maudib (---.6197.cust.vallnet.com)
Date: December 17, 2006 10:10PM

Thanks for the reply.

Let me try again.

I want to take an inbound URL like this one:

[test.mydomain.com]

and based on the fact that the entire URL contains: "test.mydomain.com"

make the URL rewrite as:


[test.mydomain.com]


I realize that this may seem strange - but the ProxyPass and ProxyPassReverse would then take this new URL and send it to my secondary application server (running on a different port of the same machine).

When the application server gets the URL, it can easily (and quickly/accurately) extract the:

ID=test.mydomain.com

which it will use to determine what client website it is serving.


Notes:

The application server can literally have thousands of client websites that are using CURL to send traffic to the main Apache server (by IP address).

If I was to construct the CURL url to simply have the: ID=test.mydomain.com appended to the URL, I would not need to do this.

However I want to let the Apache server do the work of determining what client website is attaching to it.

It does this well with the VirtualHost entry, but now I want the URL that Apache will send to the application server (with ProxyPass) to have the ID=test.mydomain.com added to the original URL.

In this manner - ANY of the URLs sent to the application server have the ID=test.mydomain.com added to them and the application server is able filter based on the value of "ID".


I hope this makes better sense - sorry for the long post.

Thanks!

Options: ReplyQuote
Re: Mod Rewrite Question
Posted by: steveryherd (---.central.biz.rr.com)
Date: December 18, 2006 01:29AM

I don't understand why you can't just get the SERVER_NAME in apache/php like normal?


Options: ReplyQuote
Re: Mod Rewrite Question
Posted by: Maudib (---.6197.cust.vallnet.com)
Date: December 18, 2006 01:56AM

I'm sorry - but how does that help me pass the SERVER_NAME (assuming that with the virtualhost it would be the correct one) to the proxied server as a parameter to the URL?


More data...

I have a dedicated server in a data center with ONE IP address.

I want to run Apache server as a front end (using the virtualhost capability) to serve MULTIPLE inbound URLS that are coming from different domains on the Internet.

Then when traffic from the given domain comes in (using PHP CURL) - I need to ProxyPass that traffic to a NON-Apache application server running on a different port on the same machine.

That application server generates custom content based on the page requested AND the domain the request came from.

The ProxyPassReverse the returns the "custom" page back to the CURL of website where the URL originated.



Now all this works fine.


What I want to do is rewrite the URL as it passes through the Apache server so that the NON-Apache application server does not have to waste time parsing the URL to determine the website of origin.

Since my original post I have found that I can get this using the %{HTTP_HOST} variable, so I am making some progress.


Now I just need to figure out the rewrite rule that will essentially say this:

Original_URL /Original_URL?ID=%{HTTP_HOST}

or

rewrite the original URL so that it has

?ID=%{HTTP_HOST}

appended to the end of it.


Does that help make sense now?


Thanks!



?URL=%{HTTP_HOST}

Options: ReplyQuote


Sorry, only registered users may post in this forum.