Tags:
development1Add my vote for this tag installation1Add my vote for this tag create new tag
, view all tags

TWiki on Nginx

nginx-logo.png Instructions to install TWiki on high performance Nginx webserver (pronounced "Engine-X")

Download and install TWiki

See TWikiInstallationGuide.

Nginx-specific configuration

Access restriction

You should restrict access to the configuration script and all twiki directories except the bin and pub directories.

The following code is a concrete example.

location ~ ^/twiki/ {
    deny all;

    location ~ ^/twiki/pub/ { allow all; }

    location ~ ^/twiki/bin/configure {
        #allow          *.*.*.*; # When you configure your TWiki, remove "#" and set your IP address.
        fastcgi_pass   127.0.0.1:8999;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

    location ~ ^/twiki/bin/ {
        allow all;
        fastcgi_pass   127.0.0.1:8999;
        fastcgi_split_path_info  ^(/twiki/bin/[^/]+)(/.*)$;
        include        fastcgi_params;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
}

Enable PATH_INFO

Use fastcgi_split_path_info directive and fastcgi_param directive in order to enable the PATH_INFO environment variable. Refer to above code.

URL shortening

If you edit your LocalSite.cfg and add the following:

$TWiki::cfg{ScriptUrlPaths}{view} = '/twiki';
$TWiki::cfg{ScriptUrlPaths}{edit} = '/twiki/edit';

you should add the following to your nginx.conf:

rewrite ^/twiki/([A-Z].*)  /twiki/bin/view/$1;
rewrite ^/twiki/edit/(.*)  /twiki/bin/edit/$1;

The entire code is as follows:

location ~ ^/twiki/ {

    rewrite ^/twiki/([A-Z].*)  /twiki/bin/view/$1;
    rewrite ^/twiki/edit/(.*)  /twiki/bin/edit/$1;

    deny all;

    location ~ ^/twiki/pub/ { allow all; }

    location ~ ^/twiki/bin/configure {
        #allow          *.*.*.*; # When you configure your TWiki, remove "#" and set your IP address.
        fastcgi_pass   127.0.0.1:8999;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

    location ~ ^/twiki/bin/ {
        allow all;
        fastcgi_pass   127.0.0.1:8999;
        fastcgi_split_path_info  ^(/twiki/bin/[^/]+)(/.*)$;
        include        fastcgi_params;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
}

This will change your TWiki URLs from:

www.example.com/twiki/bin/view/Main/WebHome to www.example.com/twiki/Main/WebHome

www.example.com/twiki/bin/edit/Main/WebHome to www.example.com/twiki/edit/Main/WebHome

References

-- Contributors: KoheiYoshioka - 2012-09-25

Discussion

Thank you very much Kohei-san for documenting the Nginx installation! Yet another useful enhancement for the TWiki community.

I added links in appropriate places to this topic.

-- PeterThoeny - 2012-09-25

Feedback in KampalaReleaseMeeting2013x10x24 on TWiki on Nginx installation:

  1. configure nginx.conf with proper server{} section pointing to your http dir;
  2. move the twiki dir into it;
  3. installed these modules: local::lib, CGI-Session-4.48, FreezeThaw-0.5001, Time-modules-2013, GD-2.50, Rcs-1.05;
  4. install fcgi-wrapper and spawn-fcgi.
  5. create script with case--switch statements to manage launch/reset;
  6. and login to nginx

BTW, I do not recommend to expose the whole twiki dir as http enabled, this can be a security risk. Only the twiki/pub needs to be http enabled, and the twiki/pub CGI enabled.

-- Peter Thoeny - 2013-10-25

Here is another installation instruction: http://www.bdunk.com/twiki-nginx

-- Peter Thoeny - 2014-01-23

Another sample configuration is at Support.SID-00831, contributed by FangXing.

-- Peter Thoeny - 2015-11-09

Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2015-11-09 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.