summaryrefslogtreecommitdiff
path: root/templates/logs.vhost.erb
blob: 436fc820251e5258ba14da03fa19e261eb9ee36f (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- apache -*-
# ************************************
# Managed by Puppet
# ************************************

NameVirtualHost <%= @vhost_name %>:<%= @port %>
<VirtualHost <%= @vhost_name %>:<%= @port %>>
  ServerName <%= @srvname %>
<% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%>
<%= " ServerAlias #{@serveraliases}" %>
<% end -%>
  DocumentRoot <%= @docroot %>

  AddType text/plain .log
  AddType text/plain .sh
  AddType text/plain .yaml
  AddType text/plain .yml

  # use Apache to compress the results afterwards, to save on the wire
  # it's approx 18x savings of wire traffic to compress. We need to
  # compress by content types that htmlify can produce
  AddOutputFilterByType DEFLATE text/plain text/html application/x-font-ttf image/svg+xml

  <FilesMatch \.html\.gz$>
    ForceType text/html
    AddDefaultCharset UTF-8
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.css\.gz$>
    ForceType text/css
    AddDefaultCharset UTF-8
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.js\.gz$>
    ForceType text/javascript
    AddDefaultCharset UTF-8
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.ttf\.gz$>
    ForceType application/x-font-ttf
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.svg\.gz$>
    ForceType image/svg+xml
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.json\.gz$>
    ForceType application/json
    AddEncoding x-gzip gz
  </FilesMatch>
  <FilesMatch \.css$>
    # mod_mime_magic is sometimes passing css files as asm sources
    # e.g css files generated by coverage reports
    ForceType text/css
  </FilesMatch>
  <Directory <%= @docroot %>>
    Options <%= @options %>
    AllowOverride None
    Order allow,deny
    allow from all
    Satisfy Any
  </Directory>
  <Directory /usr/local/lib/python2.7/dist-packages/os_loganalyze>
    Allow from all
    Satisfy Any
  </Directory>

<% @readmes.each do |pattern, helpfile| -%>
  <Directory <%= @docroot %><%= pattern %>>
    ReadmeName <%= helpfile %>
  </Directory>
<% end -%>

  <Directory <%= @docroot %>/periodic*/*>
     IndexOrderDefault Descending Date
  </Directory>

  RewriteEngine On
  # If the specified file does not exist, look if there is a gzipped version
  # If there is, serve that one instead
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.gz -f
  RewriteRule ^/(.*)$ %{REQUEST_URI}.gz

  # rewrite txt.gz & console.html[.gz] files to map to our internal htmlify
  # wsgi app
  # PT, Pass-through:  to come back around and get picked up by the
  #                    WSGIScriptAlias
  # NS, No-subrequest: on coming back through, mod-autoindex may have added
  #                    index.html which would match the !-f condition. We
  #                    therefore ensure the rewrite doesn't trigger by
  #                    disallowing subrequests.
  RewriteRule ^/(.*\.txt\.gz)$ /htmlify/$1 [QSA,L,PT,NS]
  RewriteRule ^/(.*console\.html(\.gz)?)$ /htmlify/$1 [QSA,L,PT,NS]

  # Check if the request exists as a file, directory or symbolic link
  # If not, write the request to htmlify to see if we can fetch from swift
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !^/icon
  RewriteRule ^/(.*)$ /htmlify/$1 [QSA,L,PT,NS]

  WSGIScriptAlias /htmlify /usr/local/lib/python2.7/dist-packages/os_loganalyze/wsgi.py

  ErrorLog /var/log/apache2/<%= @name %>_error.log
  LogLevel warn
  CustomLog /var/log/apache2/<%= @name %>_access.log combined
  ServerSignature Off
</VirtualHost>