apache - 如何向apache 2.4.27 ProxyPass添加查询参数?

标签 apache mod-proxy query-string proxypass

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

相关文章:

php - 使用没有 WIFI 的智能手机访问 localhost 站点

apache - mod_proxy 中的 no-jk 等效项

Apache RewriteRule 代理不遵循重定向

nginx - 如何在lua或nginx中获取查询参数?

javascript - 使用 JavaScript 向 URL 添加参数

javascript - 如何在我的网站中加载 https 中的文件

apache - 启动时 Apache Tomcat 中的 PS Permgen 为 98%

python - Werkzeug 响应太慢

java - 配置 Apache/Tomcat 的最佳实践

rust - 如何在 actix-web 中接收多个具有相同名称的查询参数?