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?


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).


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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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