summaryrefslogtreecommitdiff
path: root/templates/dual-elasticsearch.vhost.erb
blob: 78b3394473fe67e42d112b156e319284a2afda7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<VirtualHost *:80>
  ServerName <%= @vhost_name %>
  ServerAdmin <%= @serveradmin %>
<% if @serveraliases.is_a? Array %>
<% serveraliases.each do |name| %><%= "  ServerAlias #{name}\n" %><% end %>
<% elsif @serveraliases != '' %>
<%= "  ServerAlias #{serveraliases}" %>
<% end %>

  ErrorLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-error.log

  LogLevel warn

  CustomLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-access.log combined

  <IfModule mod_proxy.c>
    # Proxy GETs for elasticsearch .*/_aliases, .*/_status, .*/_search,
    # .*/_mapping, .*/_mapping/field/.*, _cluster/health, _cluster/state/.*,
    # _nodes. and _nodes/stats
    # These GETs allow read-only access for kibana3, elasticsearch-head, and bigdesk,
    # as well as arbitrary searches using the elasticsearch search api.
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} GET
    RewriteRule ^<%= @elasticsearch_prefix %>((.*/)?_aliases|(.*/)?_status|(.*/)?_search|(.*/)?_mapping(/field(/.*)?)?|_cluster/(health|state(/.*)?)|_nodes(/stats)?)$ <%= @elasticsearch_url %>/$1 [P]
    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule ^<%= @elasticsearch_prefix %>(_aliases|(.*/)?_search)$ <%= @elasticsearch_url %>/$1 [P]
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^<%= @elasticsearch_prefix %>((.*/)?_search)$ <%= @elasticsearch_url %>/$1 [P]
    <Proxy <%= @elasticsearch_url %>/>
      ProxySet connectiontimeout=<%= @vhost_proxy_connect_timeout %> timeout=<%= @vhost_proxy_timeout %>
    </Proxy>
    ProxyPassReverse <%= @elasticsearch_prefix %> <%= @elasticsearch_url %>/
  </IfModule>

  DocumentRoot <%= docroot %>
  <Directory <%= docroot %>>
    Options -Multiviews
  </Directory>

</VirtualHost>