In Apache how to define multiple ProxyPass to different servers with the same context-root?

Solution 1:

This is easily done with mod_proxy:

ProxyPass /rep1/ibm http://reportingserver1.example.com/ibm
ProxyPassReverse /rep1/ibm http://reportingserver1.example.com/ibm


ProxyPass /rep2/ibm http://reportingserver2.example.com/ibm
ProxyPassReverse /rep2/ibm http://reportingserver2.example.com/ibm

There is more information at the apache documentation site for mod_proxy.

If you need to change the links in the content returned from the external sites, you can do that using mod_ext_filter. Here's a sample configuration to rewrite a link:

# mod_ext_filter directive to define a filter which
# replaces text in the response
#
# Note: I'm Using a '#' instead of an '/' in the sed command since I want to
# include '/' in the string
#
ExtFilterDefine rep1 mode=output intype=text/html \
    cmd="/bin/sed s#reportingserver1.example.com/ibm#example.com/rep1/ibm#g"

<Location /rep1>
    # core directive to cause the fixtext filter to
    # be run on output
    SetOutputFilter rep1
    ProxyPass /rep1/ibm http://reportingserver1.example.com/ibm
    ProxyPassReverse /rep1/ibm http://reportingserver1.example.com/ibm
</Location>