简体   繁体   English

Apache-将虚拟主机重定向到LAN上的其他计算机

[英]Apache - Redirect virtual host to other machine on LAN

I have seen a few other SO questions around, but I can't seem to get any of them to work. 我还看到了其他一些SO问题,但似乎无法解决其中的任何问题。 I am in the process of phasing out my old webserver machine, after setting up a new, updated, host. 设置新的更新主机之后,我正在逐步淘汰旧的Web服务器计算机。 I don't want to do a full migration of my site from the old server to the new one, I just need the old one to be up for a little bit longer while the new server is net facing. 我不想将我的站点从旧服务器完全迁移到新服务器,我只需要在新服务器面向网络时将旧服务器的运行时间延长一点。

The old server is configured for the virtual host www.example.net, LAN IP 10.0.0.11. 已为虚拟主机www.example.net,LAN IP 10.0.0.11配置了旧服务器。 The new server is configured for dev.example.net, LAN IP 10.0.0.12. 新服务器配置为dev.example.net,LAN IP 10.0.0.12。 I would like the new server to serve up requests for dev.example.net, but forward requests for www.example.net (and example.net) to the old server. 我希望新服务器提供对dev.example.net的请求,但将对www.example.net(和example.net)的请求转发到旧服务器。 I have this in my www.example.net.conf in sites-available 我在www.example.net.conf中的站点中有此文件

    <VirtualHost *:80>
    ServerName example.net
    ServerAlias www.example.net.net
    RewriteEngine     On
    RewriteRule       ^(.*)$        http://10.0.0.11$1  [P]

Is there anything I am missing? 我有什么想念的吗? Does there need to be anything on the old machine's config? 旧计算机的配置上是否需要任何内容​​? With this current config I get "Forbidden You don't have permission to access / on this server." 使用当前配置,我得到“禁止您没有访问此服务器上的权限”。

The old server responds with my main site on LAN for http://10.0.0.11 , and no forbidden messages. 旧服务器以我在LAN上的主站点响应http://10.0.0.11 ,并且没有禁止的消息。

I appreciate any and all answers, and I apologize for the repeat question, but I don't quite understand how to make the other questions fit my purpose as most of those are doing full redirects, or specifically redirecting to an IP with no hostname. 我很感谢所有答案,对于这个重复的问题我深表歉意,但是我不十分了解如何使其他问题符合我的目的,因为大多数问题都在进行完全重定向,或者专门重定向到没有主机名的IP。

One possible reason for your error messages is not having loaded the mod_proxy module on your new server. 出现错误消息的可能原因之一是没有在新服务器上加载mod_proxy模块。 The [P] causes apache to use mod_proxy to handle the flag; [P]使apache使用mod_proxy来处理标志; on my server when I removed mod_proxy from my configuration it gave 403 Forbidden messages rather apply the RewriteRule. 在我的服务器上,当我从配置中删除mod_proxy时,它发出了403条禁止消息,而是应用了RewriteRule。

Note, you could of course, simply use the [R] flag instead to cause a redirect, but that would be visible to the client browsers. 注意,您当然可以简单地使用[R]标志来引起重定向,但这对于客户端浏览器是可见的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM