New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists

Running Foswiki on Nginx

  • Tip Category - Installation and Upgrading
  • Tip Added By - DaveHayes - 03 Nov 2010 - 21:12
  • Extensions Used - FastCGIEngineContrib
  • Useful To - Beginners
  • Tip Status - New
  • Related Topics -
Updated for Foswiki 2.0, along with short URLs. See FoswikiOnNginx rev 11 for the old version of this document supporting Foswiki 1.x support.

Foswiki 2.0 ships with several configuration files ready for use with Nginx, but they do need some tailoring.


Before installing Foswiki, be sure that the Perl dependencies identified in SystemRequirements have been installed. The following packages are required for Foswiki under Nginx:
CPAN Module Debian/Ubuntu package
FCGI libfcgi-perl
FCGI::ProcManager libfcgi-procmanager-perl


These instructions are specific for Debian / Ubuntu installations. File locations and init scripts may be different on other systems.

  1. Download the Latest Foswiki release and extract it into your website directory (ex. /var/www, /srv/www, or /home/www-data )
  2. Copy tools/foswiki.defaults to /etc/default/foswiki, and tailor it for your installation. If your distribution does not use etc/default files, then these settings need to be manually inserted into the init script.
    FOSWIKI_ROOT=/var/www/foswiki             <=== Location of the expanded foswiki distribution
    FOSWIKI_BIND=               <=== Must match settings in nginx host configuration
    ... (Remaining defaults are tuning)
  3. Copy tools/foswiki.init-script to /etc/init.d/foswiki
  4. Create a file named /etc/nginx/sites.available/foswiki.conf with the following:
    server {
        listen       80;
        server_name;           <=== Replace with your hostname
        set $foswiki_root "/var/www/foswiki";    <=== Path to expanded foswiki distribution
        root $foswiki_root; 
        access_log  /var/log/nginx/foswiki-access.log;
        error_log   /var/log/nginx/foswiki-error.log debug;
        location = / {
            root $foswiki_root;
            rewrite .* /Main/WebHome;
        # Note that this does not support utf-8 web names.
        location ~ ^/([A-Z_].*)$ {
            rewrite ^/(.*)$ /bin/view/$1;
        location ~ (^/pub) {
            allow all;
        # Bootstrap will set pub to '/bin/../pub'   so only send 'bin/(alpha)' to fastcgi 
        location ~ ^/bin/([a-z]+) {
               fastcgi_param            SCRIPT_NAME     $1;
               gzip off;
               #fastcgi_pass             unix:/var/run/nginx/foswiki.sock;
               fastcgi_pass   ;            <=== Must match FOSWIKI_BIND parameters
               fastcgi_split_path_info  ^(/bin/\w+)(.*);
               fastcgi_param            SCRIPT_FILENAME $foswiki_root/$fastcgi_script_name;
               fastcgi_param            SCRIPT_NAME     $fastcgi_script_name;
               fastcgi_param            PATH_INFO       $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;
  5. Link /etc/nginx/sites.available/foswiki.conf to /etc/nginx/sites.enabled/foswiki.conf
  6. Start or restart nginx. (service nginx start or service nginx restart)
  7. Startup the foswiki fcgi handlers (service foswiki start)
  8. Navigate to your site's default URL, should be something like
  9. Follow the link in the banner from there to configure, and address any alert Warnings or ALERT! errors.

Note: With Nginx and FCGI, you must set the {SaveEnvPath}. Typically /bin:/usr/bin It will be flagged with a alert warning until it has been configured.

If you discover that the command service foswiki stop fails to stop the foswiki fcgi processes, verify that the module FCGI::ProcManager is installed.

You should now be on your way to using foswiki with nginx.


There appears to be another page on with instructions for Nginx with FastCGI:

The instructions there appear to be slightly different.

-- ManasB 7 Jan 2017

Why is the SCRIPT_NAME parameter set twice?

I'm having issues saving updates - it appears the arguments aren't passed properly.

Also, is fastcgi_params isn't necessarily all that standard, from what I can see.

-- DavidAustin42 1 Jan 2016

-- Main.GeorgeClark - 02 Jan 2016 - 15:58

Prior discussion:

It occurs to me that is a dangerous URL for paranoid reasons. Here's my logic. Extensions load other Perl CPAN libraries that might be tricked into accessing a URL on on the server side. It is paranoid but restricting configure to explicit, non-loopback, IPs might be more secure.

-- DaveHayes - 09 Nov 2010

Here are the scripts I use to run foswiki under nginx

-- MichaelDaum - 13 Mar 2014

BestPracticeTipsForm edit

Category Installation and Upgrading
Related Topics
Topic attachments
I Attachment Action Size Date Who Comment
configure.fcgifcgi configure.fcgi manage 6 K 03 Nov 2010 - 19:57 DaveHayes  
foswikiEXT foswiki manage 2 K 13 Mar 2014 - 09:03 MichaelDaum  
foswiki-dav.init-scriptinit-script foswiki-dav.init-script manage 2 K 29 Apr 2014 - 15:22 MichaelDaum  
foswiki-nginx.confconf foswiki-nginx.conf manage 2 K 13 Mar 2014 - 11:15 LauHub An example of NGINX configuration file for Debian Wheezy (credits: MichaelDaum)
foswiki.init-scriptinit-script foswiki.init-script manage 2 K 15 Jan 2015 - 16:36 MichaelDaum  
Topic revision: r16 - 09 Jan 2017, ManasB - This page was cached on 17 Mar 2018 - 14:40.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License