apachetomcatproxypassajp

Apache AJP, ProxyPass : How to set the Host header


I'm trying to figure out a way to set the "Host" header content during a ProxyPass for AJP.

Here is my working conf with HTTP :

<VirtualHost *:80>
    ProxyRequests off
    ProxyPreserveHost off

    ServerName my-external-domain

    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel error

    <Location />
        ProxyPass http://my-internal-tomcat:8080/
        ProxyPassReverse http://my-internal-tomcat:8080/
        Order allow,deny
        Allow from all
    </Location>

</VirtualHost>

On the tomcat, the servername detected is my-internal-tomcat (the behaviour that I want).

Here is my second conf with AJP :

<VirtualHost *:80>
    ProxyRequests off
    ProxyPreserveHost off

    ServerName my-external-domain

    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel error

    <Location />
        ProxyPass ajp://my-internal-tomcat:8009/
        ProxyPassReverse ajp://my-internal-tomcat:8009/
        Order allow,deny
        Allow from all
    </Location>

</VirtualHost>

With this conf, on the servername detected is not my-internal-tomcat

Do you have any idea why?


Solution

  • My answer may be wrong, please correct me if not.

    You simply can't do that with AJP.