1

There's probably an existing question (or guide somewhere on the web) about this, but I couldn't find it.

We want to slowly migrate our user base from one implementation of the back end server to a new implementation on different servers.

There's already an Apache2 reverse proxy in front of the back end server.

So we'd like to proxy some source IP ranges/subnets to the new server, leaving all others redirecting to the original server. Then add to the IP ranges that proxy to the new server until they all do. Then remove the old server.

Can someone give me some pointers to how this is done in Apache?

1

You could do this using mod_rewrite for proxying. You will have to setup a rewrite condition based on the source IP and a rewrite rule with the [P] flag. Something like this should work:

RewriteCond %{REMOTE_ADDR} ^10\.2\.
RewriteRule ^/(.*) http://old-app/$1 [P]
ProxyPassReverse / http://old-app/ 

RewriteCond %{REMOTE_ADDR} ^10\.3\.
RewriteRule ^/(.*) http://new-app/$1 [P]
ProxyPassReverse / http://new-app/ 

Check http://httpd.apache.org/docs/2.2/rewrite/proxy.html for more information.

1

For me an approach would be something like this:

# /etc/httpd/conf/httpd.conf
<snip>
<If "-R '10.1.0.0/16'">
  ProxyPassReverse /app /http://new-app/app
</If>
<ElseIf "-R '192.168.1.0/24'">
  ProxyPassReverse /app /http://new-app/app
</ElseIf>
<Else>
  ProxyPassReverse /app /http://old-app/app
</Else>

From the apache manual

  • This will only work from apache 2.4 onwards, as older apache versions do not support If statements. – etagenklo Nov 26 '13 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.