Proxy ElasticSearch with mod_rewrite.

* modules/logstash/templates/kibana.vhost.erb: Use mod_rewrite to proxy
elasticsearch so that we can safely proxy _mapping. To do this safely we
need to restrict requests to GETs. Also, add _nodes to the list of
proxies URIs.

Change-Id: Ibe86dc104c429c144b31fed547034ee14f7f2e1d
This commit is contained in:
Clark Boylan 2013-10-16 12:35:13 -07:00
parent 36f28bfd95
commit 48a6fdcb15

View File

@ -8,14 +8,18 @@
CustomLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("::logstash::web::vhost_name") %>-access.log combined CustomLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("::logstash::web::vhost_name") %>-access.log combined
<IfModule mod_proxy.c>
<% if proxy_elasticsearch == true %> <% if proxy_elasticsearch == true %>
# Proxy for elasticsearch _aliases, .*/_status, and .*/_search. # Proxy GETs for elasticsearch _aliases, .*/_status, .*/_search,
<LocationMatch "^/elasticsearch/(_aliases|(.*/)?_status|(.*/)?_search|_cluster/health)$"> # .*/_mapping, _cluster/health, and _nodes.
ProxyPassMatch http://<%= scope.lookupvar("::logstash::web::discover_nodes")[0] %>/$1 connectiontimeout=15 timeout=120 RewriteEngine on
</LocationMatch> RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^/elasticsearch/(_aliases|(.*/)?_status|(.*/)?_search|(.*/)?_mapping|_cluster/health|_nodes)$ http://<%= scope.lookupvar("::logstash::web::discover_nodes")[0] %>/$1 [P]
ProxySet http://<%= scope.lookupvar("::logstash::web::discover_nodes")[0] %>/ connectiontimeout=15 timeout=120
ProxyPassReverse /elasticsearch/ http://<%= scope.lookupvar("::logstash::web::discover_nodes")[0] %>/ ProxyPassReverse /elasticsearch/ http://<%= scope.lookupvar("::logstash::web::discover_nodes")[0] %>/
<% end %> <% end %>
ProxyPass / http://127.0.0.1:5601/ retry=0 ProxyPass / http://127.0.0.1:5601/ retry=0
ProxyPassReverse / http://127.0.0.1:5601/ ProxyPassReverse / http://127.0.0.1:5601/
</IfModule>
</VirtualHost> </VirtualHost>