Thanks for the hint to mod_filter.
It seems to work now!
I had a problem with the fact, that the site uses both, the url with www. and the one without.
My configuration is:
<VirtualHost *:801>
ServerName www.dev.domain1.com
ServerAdmin office@domain2.com
SetEnvIf X-Forwarded-Proto https HTTPS=on
FilterProvider gzinflate INFLATE resp=Content-Encoding $gzip
FilterProvider replace SUBSTITUTE Content-Type $text/
FilterProvider gzdeflate DEFLATE Content-Type $text/
FilterChain +gzinflate +replace +gzdeflate
Substitute "s|domain2.com|dev.domain1.com|n"
ProxyPass / http://www.domain2.com/
ProxyPassReverse / http://www.domain2.com/
# ProxyHTMLEnable On
ProxyHTMLURLMap http://www.domain2.com/ /
ErrorLog /var/log/apache2/dev-proxy-error.log
LogLevel warn
CustomLog /var/log/apache2/dev-proxy-access.log combined
</VirtualHost>
And for the domain without www
<VirtualHost *:801>
ServerName dev.domain1.com
ServerAdmin office@domain2.com
SetEnvIf X-Forwarded-Proto https HTTPS=on
FilterProvider gzinflate INFLATE resp=Content-Encoding $gzip
FilterProvider replace SUBSTITUTE Content-Type $text/
FilterProvider gzdeflate DEFLATE Content-Type $text/
FilterChain +gzinflate +replace +gzdeflate
Substitute "s|domain2.com|dev.domain1.com|n"
ProxyPass / http://domain2.com/
ProxyPassReverse / http://domain2.com/
# ProxyHTMLEnable On
ProxyHTMLURLMap http://domain2.com/ /
ErrorLog /var/log/apache2/dev-proxy-error.log
LogLevel warn
CustomLog /var/log/apache2/def-proxy-access.log combined
</VirtualHost>
The ProxyHTMLURLMap alone is not enough, because it only replaces the exact same domain. on the domain with www the domain without wouldn't be replaced and vice versa.
I hope this helps someone. With this broad filter I would strongly suggest not using it on a production site, though!