haproxy redirect both scheme and location together
<p>I need to redirect a specific http URL first to its equivalent https and then on to a completely different https URL (don't ask why I can't just redirect the original http straight to the final https URL, this is what the client wants and the client is always right!).  Additionally I need to be able to redirect the original https to the different https too.</p>

<p>So, what I need is the ability to redirect <a href="http://foo.bar.com" rel="nofollow">http://foo.bar.com</a> => <a href="https://foo.bar.com" rel="nofollow">https://foo.bar.com</a> and then <a href="https://foo.bar.com" rel="nofollow">https://foo.bar.com</a> => <a href="https://another.foobar.com" rel="nofollow">https://another.foobar.com</a>, as well as redirecting <a href="https://foo.bar.com" rel="nofollow">https://foo.bar.com</a> => <a href="https://another.foobar.com" rel="nofollow">https://another.foobar.com</a>.</p>

<p>Currently to redirect just <a href="https://foo.bar.com" rel="nofollow">https://foo.bar.com</a> => <a href="https://another.foobar.com" rel="nofollow">https://another.foobar.com</a> I'm using this:</p>

<pre><code>acl is_new_portal hdr(host) -i foo.bar.com
redirect location https://another.foobar.com code 302 if is_new_portal 
</code></pre>

<p>with an initial bind on port 443, and I know to redirect http to https I would use:</p>

<pre><code>redirect scheme https code 302 if !{ ssl_fc }
</code></pre>

<p>(using code 302 rather than 301 as eventually another.foobar.com will be removed, so I don't want the redirection permanently cached in clients' browsers)</p>

<p>but I need to be able to do both relocations, and I'm not sure how you combine the two?</p>