我想将多个面向客户的 URL 映射到单个内部端点,但使用查询参数来识别每个客户。
例如客户输入 https://external_host/customer1
我想要一个反向代理将其转发为 https://internal_host/app?customer=cust1
我尝试过以下方法:
<Location "/customer1" >
RewriteEngine On
RewriteRule /customer1 /customer1?customer=cust1 [QSA,P]
ProxyPass https://<internal host>/app
ProxyPassreverse https://<internal host>/app
</Location>
<Location "/customer2" >
RewriteEngine On
RewriteRule /customer2 /customer2?customer=cust2 [QSA,P]
ProxyPass https://<internal host>/app
ProxyPassreverse https://<internal host>/app
</Location>
基本代理的工作方式是将请求转发到内部服务器,但不添加查询参数。
从我完成的所有阅读中,我觉得应该可以做我想做的事,但无法让它发挥作用。
非常感谢您的指点。
问候 克里斯
最佳答案
我解决了这个问题,如下:
ProxyRequests off
ProxyPass /app http://<internal server>/app
ProxyPassReverse /app http://<internal server>/app
RewriteEngine on
RewriteRule ^/cust1.htm /app?client=cust1.htm [QSA,P]
RewriteRule ^/cust2.htm /app?client=cust2.htm [QSA,P]
克里斯
关于apache - 如何向apache 2.4.27 ProxyPass添加查询参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52281338/