Apache:反向代理从另一台服务器处理 PHP
我有以下设置:
- 普通服务器:以纯文本形式传递 php 文件
- 代理服务器:向普通服务器询问 php 文件并解析它。
现在我的问题是:如何配置代理服务器(带有 PHP 5.3 的完全可配置的 apache 2.2)来解释来自普通服务器的纯 php 文件?
示例:在 Plain-Server 上给定一个小型 php 脚本“hello.php”(可访问 throw http://plainserver/hello.php ):
<?php
echo "Hello World";
?>
Plain-Server 仅将其输出为纯文本,不解析 php 代码。
在代理服务器上,文件“hello.php”不存在。但是,当从代理服务器请求 hello.php 时,它应该使用 mod_proxy(反向代理)从普通服务器获取 hello.php。它还应该解析并执行 php,只说“Hello World”。
反向代理已经在运行,但是 php 代码的执行不起作用。我尝试了 mod_filter,但不能工作。有什么想法吗?
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 throw 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 is work. Any ideas how to that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以考虑通过 nfs 安装或类似于目标服务器的方式从源服务器共享 php 文件。欺骗代理服务器做你要求的事情似乎是绕谷仓的很长的路?
You may consider instead sharing the php files from your source server via an nfs mount or something similar to your target server. Tricking the proxy server into doing what you ask seems like the long way around the barn?
我完全同意 jskaggz 的观点,
你可以构建一些可怕的技巧来构建一些获取远程页面的应用程序,
将其下载到本地文件中,然后将用户重定向到可以执行的页面...
但存在数以百万计的安全问题以及可能出现问题的事情......
难道你不能将“普通服务器”转换为 php 执行服务器并执行一些传统的反向代理吗
在您的“代理服务器”上
也许使用 mod_proxy:
http://www.apachetutor.org/admin/reverseproxies ?
I totally agree with jskaggz,
you could build some awfull tricks building some apps that fetch the remote page ,
dowload it into a local file and then redirect the user to that page that could be executed...
but there is a milion security issues and things that might go wrong with that...
Can't you just convert the 'plain server' to a php excuting server and do some traditional reverse proxying
on your 'proxy server'
maybe using mod_proxy:
http://www.apachetutor.org/admin/reverseproxies ?
在此线程的 ServerFault 版本上回答了这个问题:https://serverfault.com/a/399671/48061
Answered this on the ServerFault version of this thread: https://serverfault.com/a/399671/48061