The 404 plugin is not working with nginx here:

Error: "do" parameter missing

If i use the shell script for lighttpd, ikiwiki answers

Error: missing page parameter

Might this be a mistake by me or does anyone know a workaround to get the 404 plugin working with nginx? --?bacuh

The 404 plugin relies on environment variables set by Apache for 404 handlers. Not all web servers set the same variables (404 handlers aren't a standard feature) so it might need adapting to support nginx. (lighttpd has a similer problem - it doesn't indicate that the request was a 404 in an obvious way.)

If you temporarily set this (shell!) CGI script as your 404 handler, its output should indicate what variables nginx sets:

#!/bin/sh
printf "Content-type: text/plain\r\n\r\n"
env
Comment by smcv Thu May 26 02:58:04 2011

I checked the script's output and some nginx documentation. The only variable I could not find is $REDIRECT_URL. Also I could not discover any equivalent. Trying to define the variable myself in nginx's config does not help out.

Any ideas? (Should I provide env?)

Comment by bacuh [xlogon.net] Thu May 26 06:48:12 2011
The relevant environment variables used by the plugin are REDIRECT_STATUS (should be "404") and REDIRECT_URL. I doubt it can be made to work if ngix does not provide the URL or some other indication of the page that is 404ing..
Comment by joey Fri Jun 3 12:48:04 2011

I just have the following in my nginx config, which isn't as friendly, I think, as a 404 plugin, but it does the job:

    location / {
        index  index.html index.htm;
        if (!-d $request_filename) {
           rewrite ^/(.*)/$ /ikiwiki.cgi?page=$1&do=create last;
           rewrite ^(.*)/$ /$1.html last;
           rewrite ^(.*)/$ /$1.htm last;
        }
        if (!-e $request_filename) {
           rewrite ^/(.*)$ /ikiwiki.cgi?page=$1&do=create last;
           rewrite ^(.*)$ $1.html last;
           rewrite ^(.*)$ $1.htm last;
        }
    }
Comment by tychoish [livejournal.com] Sat Jun 4 08:57:14 2011
Is this what you are after ? --Mick
Comment by Mick Sat Jun 25 08:00:24 2011

This works fine for me with nginx:

location /wiki {
    error_page 404 @ikiwiki404;
}

# Another definition for ikiwiki.cgi, only reachable by error_page 404.
location @ikiwiki404 {
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
    fastcgi_index ikiwiki.cgi;
    fastcgi_param SCRIPT_FILENAME   /srv/www/htdocs/wiki/ikiwiki.cgi;
    fastcgi_param DOCUMENT_ROOT      /srv/www/htdocs/wiki;

    # For 404 plugin
    fastcgi_param QUERY_STRING "";
    fastcgi_param REQUEST_METHOD "get";
    fastcgi_param REDIRECT_STATUS 404;
    fastcgi_param REDIRECT_URL $uri;

    include /etc/nginx/fastcgi_params;
}
Comment by Roland Tue Mar 3 07:23:51 2015