Commit c7e09fc0 authored by André Kerkhoff's avatar André Kerkhoff
Browse files

Add dependencies for XSendFileContrib and configure XSendFile for Apache

parent eddb051d
......@@ -158,3 +158,5 @@ Foswiki's robots.txt can be configured with `['foswiki']['robots']['crawl_delay'
## Apache configuration
Optionally you can use the `foswiki::apache` recipe. See `attributes/apache.rb` for attributes which are used in it. It only includes the apache2 cookbook and configures a web_app resource. The web_app template `templates/web_app.conf.erb` can be used in custom wiki installations, as well.
The recipe automatically configures FCGI and XSendFile if the plugins [FastCGIEngineContrib](https://foswiki.org/Extensions/FastCGIEngineContrib) or [XSendFilePlugin](https://foswiki.org/Extensions/XSendFileContrib) are listed in `['foswiki']['plugins']`.
......@@ -19,6 +19,7 @@ default['foswiki']['apache']['server_name'] = node['fqdn']
# Regular expressions for attachments which should be ignored when protect_attachments is set
# :default means [^/]+\.(gif|jpe?g|ico)$, System/(.*)$ and ([^/]+/)+WebPreferences/([^/]+)$
default['foswiki']['apache']['unprotected_attachments'] = :default
default['foswiki']['apache']['use_fcgi'] = true
default['foswiki']['apache']['use_fcgi'] = false # true if FastCGIEngineContrib is installed
default['foswiki']['apache']['use_short_urls'] = true
default['foswiki']['apache']['use_tls'] = false
default['foswiki']['apache']['use_xsendfile'] = false # true if XSendFileContrib is installed
......@@ -183,6 +183,9 @@ module Foswiki
apt: %w(libencode-perl libhtml-html5-entities-perl libhtml-parser-perl),
foswiki: %w(TopicTitlePlugin),
},
XSendFileContrib: {
apt: %w(libfile-mmagic-perl),
},
}.freeze
INDEPENDENT_PLUGINS = %w(AutoTemplatePlugin AutoViewTemplatePlugin BehaviourContrib CommentPlugin CompareRevisionsAddOn CopyContrib EasyMacroPlugin EditTablePlugin ExternalLinkPlugin FamFamFamContrib FilterPlugin FlexFormPlugin GridLayoutPlugin HistoryPlugin HomePagePlugin InterwikiPlugin MailerContrib MimeIconPlugin PatchFoswikiContrib PreferencesPlugin PubLinkFixupPlugin RenderFormPlugin RenderListPlugin SecurityHeadersPlugin SlideShowPlugin SmiliesPlugin SpreadSheetPlugin TablePlugin TipsContrib TopicTitlePlugin TopicUserMappingContrib TrashPlugin TreeBrowserPlugin TWikiCompatibilityPlugin TwistyPlugin UpdatesPlugin ZonePlugin).freeze
......
......@@ -3,7 +3,7 @@ maintainer 'HPC'
maintainer_email 'hpc@gsi.de'
license 'All rights reserved'
description 'Installs/Configures Foswiki'
version '2.9.0'
version '2.10.0'
depends 'apache2', '< 6.0'
supports 'debian'
supports 'ubuntu'
include_recipe 'apache2'
# Some plugins hint to what Apache should do
if find_resource(:foswiki_plugin, 'XSendFileContrib')
node.default['foswiki']['apache']['use_xsendfile'] = true
end
if find_resource(:foswiki_plugin, 'FastCGIEngineContrib')
node.default['foswiki']['apache']['use_fcgi'] = true
end
apache_conf = node['foswiki']['apache'].dup
apache_conf['unprotected_attachments'] = [
'[^/]+\.(gif|jpe?g|ico)$',
......@@ -7,15 +15,38 @@ apache_conf['unprotected_attachments'] = [
'([^/]+/)+WebPreferences/([^/]+)$',
] if apache_conf['unprotected_attachments'].eql? :default
include_recipe 'apache2::mod_ssl' if apache_conf['use_tls']
# Configure mod_expires
include_recipe 'apache2::mod_expires' if apache_conf['pub_expires_time']
# Configure mod_fcgid
if apache_conf['use_fcgi']
include_recipe 'apache2::mod_fcgid'
foswiki_plugin 'FastCGIEngineContrib'
edit_resource(:foswiki_plugin, 'FastCGIEngineContrib') do
foswiki_version node['foswiki']['version']
user node['apache']['user']
group node['apache']['group']
action :install
end
foswiki_configure '{Htpasswd}{GlobalCache}'
end
# Configure mod_xsendfile
if apache_conf['use_xsendfile']
include_recipe 'apache2::mod_xsendfile'
edit_resource(:foswiki_plugin, 'XSendFileContrib') do
foswiki_version node['foswiki']['version']
user node['apache']['user']
group node['apache']['group']
action :install
end
foswiki_configure '{XSendFileContrib}{Header}' do
value 'X-Sendfile'
end
end
# Configure mod_ssl
include_recipe 'apache2::mod_ssl' if apache_conf['use_tls']
# Collect data for web_app
dirs = {}
%w(data install locales pub script template tools).each do |dir|
......@@ -61,4 +92,5 @@ web_app apache_conf['server_name'] do
use_fcgi apache_conf['use_fcgi']
use_short_urls apache_conf['use_short_urls']
use_tls apache_conf['use_tls']
use_xsendfile apache_conf['use_xsendfile']
end
......@@ -113,7 +113,13 @@
#RewriteRule ^/+pub/+images/+.*$ - [L,PT]
# If it makes it here, rewrite as viewfile
RewriteRule ^<%= @params[:pub_url_path].gsub('/', '/+') %>/+(.*)$ <%= @params[:script_url_path] %>/viewfile/$1 [L,PT]
<% viewfile = 'viewfile' -%>
<% if @params[:use_xsendfile] -%>
<% viewfile = 'xsendfile' -%>
XSendFile on
XSendFilePath "<%= @params[:pub_dir] %>"
<% end -%>
RewriteRule ^<%= @params[:pub_url_path].gsub('/', '/+') %>/+(.*)$ <%= @params[:script_url_path] %>/<%= viewfile %>/$1 [L,PT]
<% end -%>
<% end -%>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment