Php – Apache: reverse proxy to process PHP from another server

apache-2.2httpdPHPreverse-proxy

I have the following setup:

  • Plain-Server: Delivering php-files as plain text
  • Proxy-Server: Asking the Plain-Server for the php file and parsing it.

Now my question: How do I configure the Proxy-Server (a fully configurable apache 2.2 with PHP 5.3) to interpret the plain php files from Plain-Server?

Example: Given a small php script "hello.php" on Plain-Server (accessible through http://plainserver/hello.php):

<?php
echo "Hello World";
?>

Plain-Server only outputs it as plain text, no parsing of php-code.

On the Proxy-Server the file "hello.php" does not exist. But when requesting hello.php from Proxy-Server it should get the hello.php from Plain-Server with mod_proxy (Reverse Proxy). It should also parse and execute the php, saying only "Hello World".

The Reverse Proxy is already running, but the execution of php code not working. I tried mod_filter, but couldn't make it work. Any ideas how to that? (Note: Also posted on stackoverflow.com)

Best Answer

You don't. Well, not with mod_proxy, anyway. You could have a proxy PHP script that requests the content and evals it, but... ugh.

Whatever you're doing, it's fair to say you're doing it wrong.

Related Topic