I'm trying to set up an Apache server for test purposes. The goal is to simulate a load balancer. The part we're trying to simulate is simply accepting a clients secure httprequest and pass it on (via unsecure HTTP) to the correct server using ProxyPass
. This all works 100%.
The problem is this: I want to use this "load balancer" for several development environments. To be able to test the server-side of the applications, I want ProxyPass
to use a variable URL to pass to, being the client’s IP. This will require using a variable URL in the ProxyPass
rule. I’ve found the variable REMOTE_ADDR
, but I cannot seem to use this in the ProxyPass
rule. I first tried the syntax that the Apache website told me to use, but that didn’t work (getting a DNS lookup failure for http://REMOTE_ADDR/foobar/
). I know I have to do something with Interpolate
, but I cannot seem to figure out what exactly that would be.
This line does what it should do, so the server works great:
ProxyPass / http://localhost:81/
These are the rules I've tried (using the variable) which failed.
ProxyPass / http://${REMOTE_ADDR}:81/
Error: [client 127.0.0.1] proxy: DNS lookup failure for: ${remote_addr} returned by /
ProxyPass / https://%{REMOTE_ADDR}s/
Error: [client 127.0.0.1] proxy: DNS lookup failure for: %{remote_addr}s returned by /
ProxyPassInterpolateEnv On
...
ProxyPass / http://${REMOTE_ADDR}:81/ interpolate
Error: [client 127.0.0.1] error parsing URL //:81: Invalid host/port
Anyone any ideas?
You can replace Proxypass instructions by mod_rewrite rules with the [P] code, P means proxy.
Mod_rewrite will let you do more specific things.