Apache mod_substitute on HTTP requests to reverse-proxied host

Solution 1:

Why not do the following: Define two DNS names for your external printer, eg.

printer-1-external.mydomain.com CNAME external-server.mydomain.com
printer-2-external.mydomain.com CNAME external-server.mydomain.com

You could even use the same names as you use internally. Have the internal DNS resolve printer names directly to the printer, and the external DNS to your external IP...

Add two name based virtual hosts on your server:

<VirtualHost *:80>
    ServerName printer-1-external.mydomain.com
    ProxyPass / http://printer-1-local-ip/
</VirtualHost>
<VirtualHost *:80>
    ServerName printer-2-external.mydomain.com
    ProxyPass / http://printer-2-local-ip/
</VirtualHost>

That way your IPP request for http://printer-2-external.mydomain.com/printer will have the correct service name in its post parameters.

Solution 2:

Sorry I can't add comments, however, if you have not already, check to to see if:

ProxyPreserveHost On

is setup in your conf file.

The approach with the rewrite is good for the context root, but for the hostname issue it sounds like you would want to check the ProxyPreserveHost.

http://httpd.apache.org/docs/2.2/vhosts/examples.html