【问题标题】:How to add a query parameter to apache 2.4.27 ProxyPass?如何向 apache 2.4.27 ProxyPass 添加查询参数?
【发布时间】:2018-09-23 22:28:54
【问题描述】:

我想将多个面向客户的 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>

基本代理工作,请求被转发到内部服务器,但不添加查询参数。

从我所做的所有阅读中,我觉得应该可以做我想做的事,但不能让它发挥作用。

感谢您的指点。

问候 克里斯

【问题讨论】:

    标签: apache mod-proxy query-parameters proxypass


    【解决方案1】:

    我解决了这个问题:

    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]
    

    克里斯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-12
      • 2020-04-13
      • 2010-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多