[ic] Nginx config

Josh Lavin jlavin at endpoint.com
Thu Aug 27 00:46:40 UTC 2015


I recently attempted running Interchange 5.8.2 on Nginx, rather than
Apache.

In case it helps someone later, below are my configs that worked with
the Strap template, using "/cgi-bin/strap" as the URL.

These are what I used for for CentOS 7, based on info from older posts
to this list, which mostly worked, but not fully.

YMMV.

Linked here:
https://gist.github.com/jdigory/50fc9cf94cd7ea5e8e4f

Included below:

-----
/etc/init.d/fcgiwrap (systemd, I know, I know, but this still works)
----

# fcgiwrap launcher, /etc/init.d/fcgiwrap
# see: https://github.com/gnosek/fcgiwrap
# and: https://web.archive.org/web/20130324035657/http://nginx.localdomain.pl/wiki/FcgiWrap
# props: https://web.archive.org/web/20130322054803/http://www.tonimueller.org/blog/2012/09/hosting-interchange-on-nginx.html
#
#!/usr/bin/perl
 
use strict;
use warnings FATAL => qw( all );
 
use IO::Socket::UNIX;
 
my $bin_path = '/usr/local/sbin/fcgiwrap';
my $socket_path = $ARGV[0] || '/run/nginx/cgi.sock';
my $num_children = $ARGV[1] || 1;
 
close STDIN;
 
unlink $socket_path;
my $socket = IO::Socket::UNIX->new(
    Local => $socket_path,
    Listen => 100,
);
 
die "Cannot create socket at $socket_path: $!\n" unless $socket;
 
for (1 .. $num_children) {
    my $pid = fork;
    die "Cannot fork: $!" unless defined $pid;
    next if $pid;
 
    exec $bin_path;
    die "Failed to exec $bin_path: $!\n";
}

----
/etc/nginx/nginx.conf
----

server {
    # [snip] various other configs for this server.

    # ic stuff, running as /cgi-bin/strap:
    
    location  /strap {
        root  /home/josh/www;
    }
    location  /interchange-5 {
        root  /home/josh/www;
    }
    location ^~ /cgi-bin {
        root         /home/josh/www;
        fastcgi_pass unix:/run/nginx/cgi.sock;
        gzip off;
        expires off;

        set $path_info $request_uri;
        if ($path_info ~ "^/cgi-bin/strap/([^\?]*)") {
            set $path_info $1;
        }

        include                     fastcgi_params;
        fastcgi_read_timeout        5m;
        fastcgi_index               /cgi-bin/strap;

        fastcgi_param SERVER_SOFTWARE NginxEncoded/$nginx_version;  # not in Toni's
        fastcgi_param SCRIPT_NAME /cgi-bin/strap;
        fastcgi_param SCRIPT_FILENAME /home/josh/cgi-bin/strap;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTP_COOKIE $http_cookie;
    }
}

-- 
Josh Lavin
End Point Corporation



More information about the interchange-users mailing list