I don't know why the substitute directive is not working. The backend app that is behind the reverse proxy is Liferay and because it's generate absolute url, I have to make the substitution in the proxy. Moreover, I need to change the host name before the request is sent to the backend app.

Here's my httpd conf:

 <VirtualHost *:443>    
      ServerName site1.example.com
      SSLEngine On
      SSLCertificateFile /etc/httpd/conf/any.example.com.crt
      SSLCertificateKeyFile /etc/httpd/conf/any.example.com.key
      ProxyPass /Shibboleth.sso/ !
      ProxyPass /
      ProxyPassReverse /
      RequestHeader set Host "site2.example.com"
      ProxyPreserveHost On # Mandatory for changing the host
      AddOutputFilterByType SUBSTITUTE text/html
      Substitute "s|site2.example.com|site1.example.com|ni"

The problem is I always get in the result (html) urls that points to site2.example.com. For example, I have:

<a href="https://site2.example.com/link">Here!</a>
  • Your configuration looks perfectly correct. Do you have other virtualhosts in your setup? Add specific customlog entries to this one and make sure you are "landing" in it with your requests. – ezra-s Oct 6 '16 at 14:20
  • 1
    Once you've verified things as @ezra-s mentions you can consider the following. You are proxying all requests to a back end service. You need to make sure that service is sending responses that have the Content-type: text/html header. Also Setting the Host header explicitly and setting ProxyPreserveHost On doesn't seem to make much sense. – Unbeliever Oct 7 '16 at 12:57
  • Quite late, but I had a similar issue other may find useful: Httpd Location directive seems to suppress Substitute – watery Jun 8 '18 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.