Use supervisor to run fastcgi behind nginx.
Contents
Previously I wrote how to get the WlzIIPSrv large image server running on webfaction, using lighttpd.
Fast-forward 2.5 years, and I was busy porting the whole site (again), this time from webfaction (acquired by godaddy, who are planning to kill the great webfaction product), along with all of my other websites (including this one that you’re reading), to a fast, self-managed Hetzner VPS in Nuremberg.
I needed to get that exact same WlzIIPSrv large image slice server fastcgi running, but this time behind nginx and preferably without lighttpd.
I could not find the solution quickly, so I thought I’d write up what I came up with.
In short: Unlike apache and lighttpd, nginx does not manage your fastcgi processes, so you need something that can manage and expose them to nginx via socket, much like what php-fpm does for the php world.
It turns out supervisor has explicit support for fastcgi, and it is exactly what I used in this case to get the slice server running again.
Just to jog your memory as to what it is we’re trying to achieve, below is a screenshot of slice 25 of human orbit S2897L, zoomed in to maximum magnification:
As you pan and zoom around that image, five WlzIIPSrv processes are serving up the requested image tiles.
Configure supervisor.
On Ubuntu, install with apt install supervisor
.
Now create a file /etc/supervisor/conf.d/visorb_wlziipsrv.conf
that looks
something like the following:
|
|
… and then restart supervisor with systemctl restart supervisor
.
Configure nginx.
Below I show the two main location blocks in the relevant nginx server {
block for context, but the third location block is the most important.
I used the same path where the frontend scripts had been configured to find
wlziipsrv.fcgi
.
Other than that, the most important bit is that the unix socket location should match what was configured in supervisor. nginx will pass through request information via this socket, and supervisor will hand that information over to the five wlziipsrv processes that it’s managing.
|
|
Activate the new configuration as per usual, by first running nginx -t
to
check the config, and then systemctl reload nginx
to get nginx to load it.