Forum Moderators: phranque

Message Too Old, No Replies

Reverse Proxy

         

johnboy68

7:43 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



I need help figuring out how to setup my Apache2 (running on Linux) to reverse proxy an internal webserver.

I have it almost there. I can setup a reverse to say...

if I put /someplace on the end of the url to the webserver I am using as the reverse proxy. What I want to do is be able to put in:

www.someplace.com

and my reverse proxy get that from my internal webserver that is hosting that content.

www.someplace.com is a domain (fictional for this purpose) I have registered and will resolve to a real IP. Of course I only have one real IP.

Anyway, I have searched and searched and I cannot find the answer.

jdMorgan

10:17 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you could set up a virtual server on the front-end machine for that domain, then use mod_rewrite either to proxy the requests to the back-end, or to rewrite the requested URL into the "/someplace" form, so that mod_proxy will then pick it up and pass to back-end.

See the mod_rewrite RewriteRule [P] flag for the first method.

If you want to point both domains to the same virtual server, then your mod_rewrite rule would have to check the %{HTTP_HOST} variable so that only the back-end server's domain would be proxied.

Jim

johnboy68

10:14 am on Aug 29, 2007 (gmt 0)

10+ Year Member



WOW do I have a lot to learn. Mod_rewrite is very intimidating to a newbee such as my self.

Can you give me some more direction? Here is what I am trying todo:

www.frontend.com resolves to my real IP address
www.backend.com also resolves to my real IP address

for reasons that I cannot change the two "sites" are on two different webservers. I can only port forward my router to one of the webservers at a time. So what I need to do is setup the www.frontend.com server to reverse back to www.backend.com.

I have figured out how to use:

ProxyPass and ProxyReversePass so that I can go to www.frontend.com/backend to get to the backend webserver but that doesn't do me any good since people on the internet want to type in www.backend.com into their web browser...

Any help would be greatly appreciated. I would think my scenario is very basic but I am having the toughest time finding an answer.

John

jdMorgan

12:48 pm on Aug 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As stated above, the public DNS for backend.com should point to the IP address for frontend.com.

frontend.com then reverse-proxies to the backend server using its local area network IP address, not a domain name.

I suppose you could configure the 'hosts' file on these machines so that they both treat backend.com is a LAN IP address. That might simplify things, or it might not...

If most of this is new to you, just take it slow and read a lot. Setting up this kind of configuration is NOT a beginner's project, it's an intermediate-to-advanced project, and will take some serious study. Step-at-a-time, you'll get there.

Jim

johnboy68

1:28 pm on Aug 29, 2007 (gmt 0)

10+ Year Member



<quote>As stated above, the public DNS for backend.com should point to the IP address for frontend.com.</quote>

It does

<quote>frontend.com then reverse-proxies to the backend server using its local area network IP address, not a domain name.</quote>

This is the point of my problem. I can't find any documentation that tells me HOW to do it.

jdMorgan

2:43 pm on Aug 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does this [httpd.apache.org] help?

Jim

johnboy68

3:39 pm on Aug 29, 2007 (gmt 0)

10+ Year Member



Not really (I've already read this and many more like it)

Quote from that link:

ProxyPass /foo [foo.example.com...]
ProxyPassReverse /foo [foo.example.com...]

this method just allows me to put /foo on the end of the URL for the frontend server to get to the backend server. I want to use the DNS name to get to the backend.

jdMorgan

4:51 pm on Aug 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've posted two methods you could use. For the second method, see the [P] flag of mod_rewrite's RewriteRule [httpd.apache.org]. As stated above, it will allow you a bit more flexibility.

We're not set up here to 'give you the solution' -- mostly because we don't know all the details of your site, but partly because there are a limited number of contributors here. As a result, it's a "self-help" kind of thing. Specific questions are welcome, and we'll do our best to answer them.

Thanks,
Jim