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)

link|improve this question
feedback

3 Answers

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.

link|improve this answer
feedback

I found another way with mod_ext_filter. Add the following to your httpd.conf:

ProxyPass   /test/  http://localhost:9000/
<IfModule mod_ext_filter.c>
   ExtFilterDefine parse-php mode=output intype=text/html cmd="/usr/bin/php"
</IfModule>
ProxyPassReverse   /test/  http://localhost:9000/
<LocationMatch "\.php">
    SetOutputFilter parse-php
</LocationMatch>

So it runs the external application php which is found in /usr/bin/. Bad thing about it: starting a separate process and also parsing php-files which are not part of the folder /test/.

I tried also to use fast-cgi or mod_php to parse the php-file, but couldn't make it work. Any ideas how to use fast-cgi to interpret the php-file?

link|improve this answer
feedback

it is really bad solution... but on the proxy machine do not configure any proxying, instead add

ErrorDocument 404 /index.php

and in index.php put the logic that checks $_SERVER['REQUEST_URI'], downloads code from content server and executes it with eval.

but that's bad, includes will not work... womble is right. just try another approach. if you are really desperate maybe use webdav and davfs, but that's still ugly hack, nfs would be much more efficient if you insist on hosting code on one machine and interpreting on the other.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown