Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect to another apache server on an INTERNAL IP address

Status
Not open for further replies.

jimbobiv

IS-IT--Management
Nov 18, 2004
16
GB
I wish to redirect a URL say to an internal ip address which has the SAME eternal IP address...

eg/

Server -> IP =80.11.10.9 or something, internal ip 192.168.0.1

Other machine -> connects to the internet through the server, but is running an apache server also. Reason for this is that we only have one internet connection so can only ever have one external ip.. internal ip is 192.168.0.2

Can i redirect all traffic going to to 192.168.0.2 so that it is visible on an externally connected client, and so that the 192.168.0.2's apache host settings are used.

If this makes little, i'll say what i mean, say 192.168.0.1 has #LoadModule cern_meta_module modules/mod_cern_meta.so so its NOT loading that, and 192.168.0.2 has LoadModule cern_meta_module modules/mod_cern_meta.so so it is loading that, i want the module loaded and available for use etc etc.

Any ideas, if this isnt making full sense, im happy with sum1 to make a stab in the dark, anything would help cos i dont fully understand why i cant use the proxy 'something' syntax, tried it doesnt work ;o)

James
 
You can't redirect but you sure can proxy.

Use mod_proxy to handle this. Set name based virtual hosts on the external apache and have each of these proxy to the backend server.

 
I tried that but it did not work, i used the proxy_pass idea in the virtual host defenition...

Can you post an example please ;o)

Cheers
 
<VirtualHost 10.0.0.20:80>
ServerName ProxyPass / ProxyPassReverse / </VirtualHost>


Where 10.0.0.20 is my external IP address accepting the connection.

Where internalsite.com is the name of the internal webserver to server the request.

You have two webservers running in this configuration, 10.0.0.20 and internalsite.com. User is connected to 10.0.0.20 and then 10.0.0.20 connects to internalsite.com to get the content.
 
WOW it worked, you are a genius! I think I missed the reverseproxypass bit out and i was just putting proxy pass "internal IP" it works if i put proxypass IP...

YEY thank you so much, my life is soo much more hassle free now!
 
Congrats! Enjoy the newfound power.

If you really want to get advanced check out mod_rewrite, it really comes in handy when you get heavy dynamic content servers (php/jsp/perl) and need to have one server serve the heavy requests and isolate the static requests (images etc) to server specifically tasked for that. You can get huge 10x performance improvements with minimal hardware investment.

 
Yeah i have been reading the other threads, which say about that, but i dont really understand it, i'll have to keep going through the documentation and experiment on a standalone machine until i can get that sort of stuff to work!

Erm, if i load anything other than the default PHP page i cannot find it, says:

Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /test.php.

Reason: DNS lookup failure for: 192.168.0.2test.php

Ok so do i need to put something like proxypass to get it to work, or am i just being a muppett!?
 
I'd need you to post your actual configuration elements. It looks like you left off a slash somewhere.

 
Yeah i did, it was taking the request for test.php and parsing that as: 192.168.0.2test.php instead of 192.168.0.2/test.php

I tried putting /* after the IP as i thought maybe it didnt realise that i wanted all pages from the domain to that internal IP, but that said access denied, so i deleted the * and it worked...

Im a genius hehe (accidentally)

Anyways, how come your so keen to solve other people's problems? you get paid or are you like me, you just like to help where ya can ;o)

James
 
I've been participating in online forums (via IRC and recently webboards like tek-tips) since the early 90's. I've found that engaging in this process increases my knowledge and skillset in a huge way.

So it may just seem like 'charity' but I take away much more then I leave behind.

 
Fair enough.

What is your proffession, do you run a web server? Or are you a consultant?
 
Ah i have a new problem.

I used name - based resolving for the domains on my external folder, because they are all redirected through one server, so IP resolving wont work (obviously) problem I have now is that the internal server cannot detect these names, do i have to redriect using the proxypass to the internal IP/customer1/
internal IP/customer2/
and so on, or can i do it on the internal IP apache, which is what I had hoped i could do...

James

 
I do it like this. Lets say its That site actually has two names associated with it.

-> external IP
-> internal IP

Then I redirect to which resolves to my internal system.

Then, on that internal box i use name based virtual hosts so they all share the same IP address but have different names.

As to my profession, I do software development ,engineering management, product development and web hosting through a variety of companies that I either own or work for.
 
Cool, PS that is exactly what I have done, but it doesnt resolve between site1.com and site.com that are being redirected to if that makes sense..

for now im doing this

<virtual host>

servername site1.com
proxypass i-site.com/site1/
etc

</virtual host>

<virtual host>

servername site2.com
proxypass i-site.com/site2/
etc

</virtual host>

which works but is a bit more effort to maintain...

while i have ya here, can i pick your brains...

I want a page to load or be triggered on page load of another page, without using frames..

EG/ page 1 loads, page 2 loads invisibly and then closes when done... hopefully without user noticing or being annoyed with a pop up that disappears...

James.

PS Im still at university so im not quite there yet ;o)
 
It is more difficult to maintain but thats exactly what you need to do. You have to send some sort of hostname to the backend apache so it knows what vhost to use, the requests do not really seamlessly pass through, they are proxied.

You could use javascript in your page1 do to an internal 'GET' request to a page and discard the results. That would effectively 'load the page' internally to javascript and not present to the user.

Possibly, not sure, I don't design my apps that way precisely for that reason, its pretty unpredictable.

You could do a pop-under as well.

 
Cheers i'll look into it, have a good weekend ;o)
 
OK new problem!

Using the redirect as it is, if the users do a _SERVER['REMOTE_ADDR'] command in PHP they get the server IP 192.168.0.1 returned, instead of the remote address of the client. Which is seriosuly bad news...

Any ideas what I have to do?

Is it my redirect or PHP settings do you think?
 
Correct, that is how proxy works, it re-requests the data so the remote address gets munged.

Do a header dump, I think the Via: header will get you want you want. You may need to enable it.

 
in order to do the webpage without frames the easiest thing to do would be to use php

example:

take your existing html page rename the html to php

inside that page use this tag

<?php include("page2include.php"); ?>

and this will automatically take the contents of page2include.php and insert it into your exiting page

you have to have php installed on your server though





%, 2004
 
nvm I misread your post disreagard the above post

%, 2004
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top