我正在尝试找出一种在 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/