Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a web server (let's call it C1) that is running an Apache/PHP server and it is port forwarded so that I can access it anywhere. However, there is another computer within the web server LAN that has a Apache server too (let's call it C2). I cannot change the port forwarding nor can I change the Apache server (a.k.a. install custom modules).

Is there a way to access C2 within a directory of C1? (e.g. going to www.website.org/random_dir will allow me to browse the root of C2 apache server.)

I am trying to change as little as possible of the config/other (e.g. activating modules etc.)

Is there a possible solution?

share|improve this question

3 Answers 3

You can place a script on C1 which forwards your requests to C2 and present its responses. This can be achieved using web proxies.

Try installing KnProxy or php-proxy as a first step and see if one of them fits your needs.

Using the proxy, remember to call C2 by its internal ip (which is visible to C1).

share|improve this answer

You can place a script on the folder in C1 that uses curl to get the info from C2. By naming it index.php when you visit www.website.org/random_dir you would get your behaviour.

Hoever, to access other files or folders you would have to pass them as variables like: www.website.org/random_dir?folder=another_folder/subfolder&file=my_file

Would that solution fit your needs?

share|improve this answer

Reverse proxying is the name of what you are trying to do. Apache supports it.

Reverse proxying is where a webserver forwards a HTTP request or URL to a 2nd webserver (possibly modifying it on the way), collects the response of that 2nd webserver, and delivers the result (possibly modifying the result on the way back).

This is a good place to start. I'll update this answer with some examples when/if I have time.

I will warn you about this: Reverse proxying works excellently for static content and content where the URL of the page is not "hardcoded" in any links of dynamic or Javascript-generated content. When you have a web application, or an application with its own built-in webserver (think Subsonic or uTorrent's remote access), sometimes you may be in a situation where the links the web application generates point to a different location than the one you are reverse proxying to. This is where rewrite modules come into play and it can get messy. Not all web applications can be reverse proxied successfully.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.