Forum Moderators: phranque

Message Too Old, No Replies

mod proxy

reverse proxy- Proxy

         

titus126

7:34 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



Hello All,

I have some basic knowledge about apache configuration. Now I have to configure apache server as a reverse proxy to route the request to WebSEAL. This is the task that I have to accomplish. Whenever the request ed URL contains “demojunction” route the request to backend server without any modification but if the request URL doesn’t have the “demojunction”, then append the “demojunction” and send it to the backend. We may have to use some sort of regular expression to match the value. I don’t know how to configure this. If anyone has knowledge of this, please help me.

Scenario 1

Input URL : http://example.com/demojunction/appName/foo.html

No modification is required and sends it directly to the backend server

Scenario 2

Input URL : http://example.com/appName/foo.html

Since “demojunction” is missing in the URL, I have to append it and send it to the backend.

Please help

Thanks

[edited by: jdMorgan at 9:56 pm (utc) on Oct. 9, 2007]
[edit reason] example.com [/edit]

jdMorgan

9:55 pm on Oct 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Scenario one just needs an "Alias" to the proxy server. See Apache mod_alias.
Scenario two could be done with Apache mod_rewrite.

Jim

titus126

1:58 pm on Oct 10, 2007 (gmt 0)

10+ Year Member



Jim,.

Thanks for the response. I was trying to use the "ProxyPass" and "ProxyPassreverse" to direct the call to the backend server. Here the scenario is user request something to the backend server. For instance, user might have requested for http://example.com/demojunction/appName/foo.html. In this case “demojunction” is already a part of the URL so we don’t have to do anything. If the URL requested doesn’t have “demojunction” , then append that to the URL and send it to the backend server. So I am assume, we may have to do some regular expression searching for the existence of the “demojunction” in the URL. Based on the outcome of regular expression, we have to decide on either appending it or not. I don’t know how to put the regular expression and send the request to the backend server using ProxyPass. Could you please the snippet of code to do this.

Please help.

Httpd.conf

<VirtualHost *>
ProxyPass / demojunction [sub.example.com...]
ProxyPassreverse / [sub.example.com...]
</VirtualHost>

[edited by: jatar_k at 3:56 pm (utc) on Oct. 10, 2007]
[edit reason] please use example.com [/edit]

jdMorgan

2:12 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We're not really set up as a free code-writing service here -- Demand would far outstrip the "supply" available from the few contributors to this forum. Take a look at the mod_rewrite documentation, especially the RewriteCond [httpd.apache.org] directive (which makes RewriteRules execute conditionally), and then post your specific questions here.

Having implemented a rewrite, you have two choices: Either terminate mod_rewrite processing immediately and let mod_proxy take over (using the [PT] and [L] flags on the RewriteRule [httpd.apache.org], or use mod_rewrite to invoke the reverse proxy request directly using the [P] flag on the RewriteRule. Which of these methods you choose is largely a matter of 'style.'

For info on how to get the most out of this forum, please see our forum charter [webmasterworld.com].

Thanks,
Jim

titus126

3:38 pm on Oct 10, 2007 (gmt 0)

10+ Year Member



Jim,

I appreciate your help. I don’t have nay clue how to put the RewriteCond and RewriteRule. If you can at least provide me an example, that will be a great help. I have to turn in this work by COB. I am totally clueless now.

Thanks

jdMorgan

9:41 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




# Prefix URL-path with "/some_URL-path_here/" if missing
RewriteCond %{REQUEST_URI} !^/some_URL-path_here/
RewriteRule (.*) /some_URL-path_here/$1 [PT,L]

[edited by: jdMorgan at 9:42 pm (utc) on Oct. 10, 2007]

titus126

4:39 pm on Oct 11, 2007 (gmt 0)

10+ Year Member



Thanks Jim. God bless you