带有变量的Apache代理配置

时间:2014-09-24 15:26:13

标签: apache

我尝试将apache配置为弹性搜索实例(REST服务)的代理。

直到现在我已使用LDAP配置Basic Auth。

目标是重定向
的请求 https://elasticsearch.example.de/kibana-int/dashboard/_search
http://127.0.0.1:9200/kibana-int-user1/dashboard/_search其中user1是LDAP登录名(来自REMOTE_USER)。

我用

试了一下
<LocationMatch "^/kibana-int/(?<MOREINFOS>.*)$">
    ProxyPassMatch   "http://127.0.0.1:9200/kibana-int-%{REMOTE_USER}/%{ENV:MOREINFOS}"
    ProxyPassReverse "http://127.0.0.1:9200/kibana-int-%{REMOTE_USER}/%{ENV:MOREINFOS}"
</LocationMatch>

通常可以使用LocationMatch执行此操作吗? 或者我是否必须首先进行一些重写请求的URL重写和代理?

感谢您的阅读和帮助。

1 个答案:

答案 0 :(得分:0)

经过一段时间的研究,我终于找到了解决方案。

ProxyPass*无法使用RewriteRule[P]标记:

<Location ~ "^/kibana-int/">
       Include ldapauth.conf
       RewriteEngine On
       RewriteRule /kibana-int/(.*)$ http://127.0.0.1:9200/kibana-int-%{REMOTE_USER}/$1 [P]
</Location>