I need to configure proxy with apache to proxy requests like
I tried to do this like that:
<LocationMatch ^/proxy/(.*)$> ProxyPassMatch http://$1 </LocationMatch>
But how can I make all redirects that sends to me remote host go via proxy? For example, if I go to url:
and another-site.com send me redirect to yet-another-site.com, it shall forward my browser to
You can use Apache
ProxyPassReverse directive for this. You can find its documentation in Apache documentation
I would recommend not using Location or LocationMatch blocks, just use the 2 argument versions of ProxyPass and ProxyPassMatch. So in your case:
ProxyPassMatch ^/proxy/(.*)$ http://$1
However you cannot use Apache configuration to fix back end redirects as there is no corresponging ProxyPassReverseMatch directive (this directive simply cannot work this way). You would need to edit Location, Content-Location and URI headers using the Header directive (which duplicates what the the ProxyPassReverse directive does) and possibly use mod_sed/mod_substitute to fix and hard coded URLs in the HTML.
But it will be messy, very messy. The reason this sort of thing is not easy to do is that in general Apache is not an HTML content aware server, it’s an HTTP aware server, two very different things.
It maybe slightly easier to upgrade to apache v2.4 so you can use mod_proxy_html (which is HTML aware) or write your own handler in mod_lua or similar.