Apache AJP,ProxyPass : How to set the Host header

标签 apache tomcat proxypass ajp

我正在尝试找出一种在 AJP 的 ProxyPass 期间设置“主机” header 内容的方法。

这是我使用 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>

在 tomcat 上,检测到的服务器名称是 my-internal-tomcat(我想要的行为)。

这是我与 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>

有了这个 conf,检测到的服务器名 不是 my-internal-tomcat

你知道为什么吗?

最佳答案

我的回答可能有误,如有错误请指正

您根本无法使用 AJP 做到这一点。

关于 Apache AJP,ProxyPass : How to set the Host header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47557525/

相关文章:

apache - Tomcat Manager 能否在替代路径上安全运行?

c - Apache 模块中的静态变量被多次初始化?

java - 使用 JSF 和 Tomcat 的 LDAP 身份验证

nginx proxy_pass over https_proxy

nginx - 使用 proxy_pass 配置 Nginx

python - Amazon EC2 Django 静态文件配置

PHP glob/scandir 和 Linux 软链接(soft link)/权限

java - Tomcat 中的内存分配和 GC

android - 从 Apache 到 Android 应用程序的 Cookie

apache - 将 Apache ssl 端口 443 转发到 Tomcat http 端口