Foswiki configuration on Nginx
Foswiki has a plugin for running natively as a FastCGI application. Although at first glance, one may wonder why anyone wouldn't use the native FastCGI plugin, but there are reasons for avoiding the plugin. It turn out that on some low-end systems, the cgi wrapper performs better, also CGI is easier to configure.
Beware: The
configure.pl script must be run as CGI even if Foswiki itself runs as a FastCGI application.
- start the FastCGI application, you have two ways to do that:
- configure Nginx location for foswiki
set $foswiki_root "/var/www/foswiki";
location /foswiki {
root /var/www/foswiki;
index index.html; # should be changed after installation
}
location /foswiki/bin/configure {
allow 127.0.0.1; # localhost, you may want to omit due to security considerations.
allow 192.168.12.12; # you management host if you have one
deny all;
gzip off;
fastcgi_pass unix:/var/run/nginx/perl-cgi.sock;
fastcgi_split_path_info ^/foswiki(/bin/configure)(?:\.pl)?(.*);
fastcgi_param SCRIPT_FILENAME $foswiki_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
location /foswiki/bin/ {
gzip off;
fastcgi_pass unix:/var/run/nginx/foswiki.sock;
fastcgi_split_path_info ^(\w+)(?:\.pl)?(.*);
fastcgi_param SCRIPT_FILENAME $foswiki_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $foswiki_root$fastcgi_path_info;
include fastcgi_params;
}
location ~ (^/lib|^/data|^/locale|^/templates|^/tools|^/work) {
deny all;
}
if ($http_user_agent ~ ^SiteSucker|^iGetter|^larbin|^LeechGet|^RealDownload|^Teleport|^Webwhacker|^WebDevil|^Webzip|^Attache|^SiteSnagger|^WX_mail|^EmailCollector|^WhoWhere|^Roverbot|^ActiveAgent|^EmailSiphon|^CrownPeak-HttpAgent|^$) {
rewrite .* /404.html break;
}
the fastcgi_split_path_info directive doesn't work in old (0.6*) versions of Nginx, use regex matching with the if ... set directives to split the fastcgi_script_name parameter.
- Load the Foswiki configuration wui
configure.pl and config your new wiki.
Note: The above configuration works with or without the
.pl suffix.
A few nice touches:
--
AvishaiIshShalom - 03 Sep 2009