Apache mod_perl 处理程序/调度程序将控制权返回给 apache
是否可以有一个 apache mod_perl 处理程序,它接收所有传入请求并根据一组规则决定该请求是否是它想要执行的操作,如果不是,则将控制权返回给 apache,apache 将正常处理该请求?
用例:
旧网站使用 用于服务index.html的DirectoryIndex (或类似)和默认处理程序 perl 脚本等,正在被给予 更新了 url-scheme (django/catalyst-ish)。调度员 将有一组映射到的 url 基于调度的控制器 在传入的 URL 上。
然而,棘手的部分是 该调度程序在同一 命名空间与旧主机位于同一虚拟主机上 地点。想法是重写 逐个站点,作为“全部更新” 迁移没有机会进行测试 新系统的站点性能, 由于纯粹的原因,这也是不可行的 网站的大小。
许多问题之一是调度程序现在按预期接收所有 URL,但 DirectoryIndex 和静态内容(主要由不同主机提供,但不是所有内容)未正确提供。对于不匹配的 url,调度程序返回 Apache::Const::DECLINED,但 Apache 不会像平常那样继续处理请求,而是提供默认的错误页面。 Apache似乎没有尝试寻找/index.html等。
如何解决这个问题?您需要使用内部重定向吗?更改调度程序中的处理程序堆栈?使用一些巧妙的指令?上述所有的?根本不可能吗?
欢迎所有建议!
Is it possible to have an apache mod_perl handler, which receives all incoming requests and decides based upon a set of rules if this request is something it wants to act upon, and if not, return control to apache which would serve the request as normal?
A use-case:
A legacy site which uses
DirectoryIndex for serving index.html
(or similar) and default handlers for
perl scripts etc, is being given a
freshened up url-scheme
(django/catalyst-ish). A dispatcher
will have a set of urls mapped to
controllers that are dispatched based
on the incoming url.However, the tricky part is having
this dispatcher within the same
namespace on the same vhost as the old
site. The thought is to rewrite the
site piece by piece, as a "update all"
migration gives no chance in testing
site performance with the new system,
nor is it feasible due to the sheer
size of the site.
One of the many problems, is that the dispatcher now receives all URLs as expected, but DirectoryIndex and static content (which is mostly served by a different host, but not everything) is not served properly. The dispatcher returns an Apache::Const::DECLINED for non-matching urls, but Apache does not continue to serve the request as it normally would, but instead gives the default error page. Apache does not seem to try to look for /index.html etc.
How can this be solved? Do you need to use internal redirects? Change the handler stack in the dispatcher? Use some clever directives? All of the above? Not possible at all?
All suggestions are welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不久前做过类似的事情,所以我可能有点含糊:
I have done a similar thing but a while back, so I might be a little vague:
也许您会成功使用 mod_rewrite 配置,该配置仅在文件系统中不存在所请求的文件时才将 URL 重写到您的调度程序。这样,您的新应用程序将充当旧应用程序的覆盖,并且可以通过在部署新部分期间删除应用程序的旧部分来按连续步骤进行替换。
这可以通过 RewriteCond 和 RewriteRule 的组合来实现。您的新应用程序需要位于旧应用程序中不使用的私有“命名空间”(位置)中。
我不是 mod_perl 专家,但使用例如 mod_php 它可以像这样工作:
Maybe you will have success using a mod_rewrite configuration which only does rewrite URLs to your dispatcher if a requested file does not exist in the file system. That way your new application acts as an overlay to the old application and can be replaced in successive steps by just removing old parts of the application during deployment of new parts.
This can be accomblished by a combination of RewriteCond and RewriteRule. Your new application needs to sit in a private "namespace" (location) not otherwise used in the old application.
I am not a mod_perl expert but with eg mod_php it could work like this: