2

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 / http://10.0.0.4:8080/
      ProxyPassReverse / http://10.0.0.4:8080/
      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"
 </VirtualHost>

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>
3
  • 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. Oct 6, 2016 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, 2016 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, 2018 at 7:49

0

You must log in to answer this question.

Browse other questions tagged .