简体   繁体   中英

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. I am in the process of phasing out my old webserver machine, after setting up a new, updated, host. 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. The new server is configured for 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. I have this in my www.example.net.conf in sites-available

    <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.

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.

One possible reason for your error messages is not having loaded the mod_proxy module on your new server. The [P] causes apache to use mod_proxy to handle the flag; on my server when I removed mod_proxy from my configuration it gave 403 Forbidden messages rather apply the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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