-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support Apache mod_fcgid/mod_proxy_fcgi and Nginx
TODO: Actually mod_proxy_fcgi requires further manual configuration. Import from Dieken/foswiki-docker@4fb9363
- Loading branch information
Showing
5 changed files
with
216 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name _; | ||
|
||
set $foswiki_root /var/www/foswiki; # <=== Path to expanded foswiki distribution | ||
root /var/www/html; | ||
index index.html; | ||
|
||
#access_log /var/log/nginx/foswiki-access.log; | ||
#error_log /var/log/nginx/foswiki-error.log debug; | ||
|
||
# Uncomment for htpasswd | ||
#auth_basic "FOSWiki"; | ||
#auth_basic_user_file $foswiki_root/data/.htpasswd; | ||
|
||
# raise upload limit (foswiki has its own limit : %ATTACHFILESIZELIMIT% in System/PreferenceSettings) | ||
client_max_body_size 50M; | ||
|
||
# browsers tend to search for a favicons and robots.txt in the root directory: if it is there fine, if not don't bother | ||
location /favicon.ico { | ||
root $foswiki_root; | ||
log_not_found off; | ||
access_log off; | ||
} | ||
location /robots.txt { | ||
root $foswiki_root; | ||
allow all; | ||
log_not_found off; | ||
access_log off; | ||
} | ||
|
||
location = / { | ||
root $foswiki_root; | ||
rewrite .* /Main/WebHome; | ||
} | ||
|
||
# redirect short urls to view | ||
location ~ ^/(?:bin/)?([A-Z_].*)$ { | ||
rewrite ^/(.*)$ /bin/view/$1 last; | ||
} | ||
|
||
# static files that we don't need to authenticate, i.e. css and js | ||
location ~ ^/pub/(System|Applications|images|cache)/ { | ||
root $foswiki_root; | ||
expires 8h; | ||
gzip_static on; | ||
} | ||
|
||
# any other static files need to be sanctioned by the foswiki backened | ||
location /pub { | ||
# either by the standard viewfile approach ... | ||
rewrite ^/pub/(.*)$ /bin/viewfile/$1; | ||
|
||
# or by XSendFileContrib using | ||
# | ||
# The following setting must be in LocalSite.cfg | ||
# {XSendFileContrib}{Header} = 'X-Accel-Redirect'; | ||
# {XSendFileContrib}{Location} = '/files'; | ||
#rewrite ^/pub/(.*)$ /bin/xsendfile/$1; | ||
} | ||
|
||
# internal location that sendfile serves sanctioned static files from | ||
location /files { | ||
internal; | ||
alias $foswiki_root/pub/; | ||
expires 8h; | ||
access_log off; | ||
} | ||
|
||
# deny any direct access to these directores | ||
# note that this only is required in case the document root equals the $foswiki_root | ||
location ~ (^/lib|^/data|^/locale|^/templates|^/tools|^/work) { | ||
deny all; | ||
} | ||
|
||
location ~ ^/bin/([a-z]+) { | ||
gzip off; | ||
# a request taking more than 2 minutes is considered an error | ||
fastcgi_read_timeout 120s; | ||
fastcgi_split_path_info ^/bin/(.+?)(/.*)$; | ||
fastcgi_param SCRIPT_FILENAME $foswiki_root/bin/foswiki.fcgi; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_pass 127.0.0.1:9000; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/sh | ||
|
||
set -eux | ||
|
||
service cron start | ||
|
||
httpd=${HTTPD:-nginx} | ||
module=${MODULE:-fcgid} # for Apache only | ||
|
||
unset HTTPD MODULE # unset environment variables | ||
|
||
case "$httpd" in | ||
apache) | ||
case "$module" in | ||
*fcgid) | ||
a2enmod fcgid | ||
a2dismod proxy_fcgi | ||
a2dismod perl | ||
;; | ||
|
||
*proxy_fcgi) | ||
a2enmod proxy_fcgi | ||
a2dismod fcgid | ||
a2dismod perl | ||
|
||
rm -f /var/run/foswiki.pid | ||
service foswiki start | ||
;; | ||
|
||
*perl) | ||
a2enmod perl | ||
a2dismod fcgid | ||
a2dismod proxy_fcgi | ||
;; | ||
|
||
*) | ||
echo "ERROR: unknown engine $module" >&2 | ||
exit 1 | ||
esac | ||
|
||
exec apache2ctl -DFOREGROUND -k start | ||
;; | ||
|
||
nginx) | ||
# Enable xsendfile in Nginx if XSendFileContrib is properly configured | ||
foswiki_conf=/etc/nginx/sites-enabled/foswiki.conf | ||
localsite_cfg=/var/www/foswiki/lib/LocalSite.cfg | ||
if grep -q '^\s*#rewrite.*xsendfile' $foswiki_conf && | ||
grep -q '{XSendFileContrib}{Header}\s*=\s*.X-Accel-Redirect.' $localsite_cfg && | ||
grep -q '{XSendFileContrib}{Location}\s*=\s*./files.' $localsite_cfg; then | ||
sed -i -E 's|^(\s*)(rewrite.*viewfile)|\1#\2|; s|^(\s*)#(rewrite.*sendfile)|\1\2|' $foswiki_conf | ||
fi | ||
|
||
rm -f /var/run/foswiki.pid | ||
service foswiki start | ||
exec nginx -g "daemon off;" | ||
;; | ||
|
||
*) | ||
echo "ERROR: unknown httpd $httpd" >&2 | ||
exit 1 | ||
esac |