I found a solution, it is not very elegant. It also requires some adaptation on the second server.
This comes from a project in which I had a similar problem, but in order for the servers to be "completely" (selected by a custom script that uses database resources).
This should at least work (I run my URL through a rewrite map to change it, I adapted it to use headers using RewriteCond ).
# example for server number "5" in your remote proxy network RewriteCond %{HTTP:X-CUSTOM-HEADER} 1 RewriteRule http://([a-z0-9\.]+)/(.*) http://$1.5.server.yourdomain.com$1 [P] ProxyRemoteMatch .*\.5\.server\.yourdomain\.com.* http://5.server.yourdomain.com:80
You basically adapt the URL so that it is a subdomain of your second server, and then you delete it again.
This part goes to the second (remote proxy):
<ProxyMatch "http://.*\.[0-9]+\.server\.yourdomain\.com/.*"> RewriteEngine on RewriteRule (proxy:http[s]?://.+)\.[0-9]+\.server\.premiumize\.me(.+) $1$2 ... your code ... </ProxyMatch>
The surrican
source share