On 14.09.2014 22:29, Adam Thompson wrote:
On 2014-09-14 11:58, Atanas Vladimirov wrote:
Hi,
I'm trying to run smokeping (installed via ppkg_add) with nginx
(installed via ppkg_add) and slowcgi.
Is it possible?

Not sure about the package... also not sure running smokeping under
slowcgi is sane.  It's really intended, based on the upstream docs, to
run under Apache with FastCGI; if you aren't running it fcgi, you need
pretty decent hardware to handle the invocation overhead.

I installed it from source, and got it working on a dedicated VM.  I
dedicated a VM to it because I wasn't comfortable with that much
web-accessible stuff running (ultimately) setuid root, and not
chroot'ed.

Running as FastCGI wasn't too difficult, in the end... although
figuring out how to do it took me some time.

===nginx.conf===
worker_processes  1;
error_log  logs/error.log  debug;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    index         smokeping.fcgi index.html index.htm;
    keepalive_timeout  65;
    server_tokens off;
    server {
        listen       80;
        listen       [::]:80;
        server_name  localhost;
        root         /opt/smokeping/htdocs;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root  /var/www/htdocs;
        }
        location  /smokeping.fcgi {
            fastcgi_pass   unix:/opt/smokeping/var/smokeping.sock;
            include        fastcgi_params;
        }
    }
}
===EOF===

I'm also forwarding, separately, to both you and ports@, the message I
sent to sthen@ covering what I had to do to make it work on
5.5-RELEASE with my conclusions on what would have to change in the
port.
Since nginx is no longer in base as of 5.7 (IIRC - ?) there might not
be much point in fixing the package... dunno, not my call.

Note that you need a FCGI launcher when using nginx instead of Apache;
I hacked one together in rc.local because I didn't fully understand
the problem until I had already solved it the hard way.


===rc.local snippet===
/opt/smokeping/bin/smokeping --config=/opt/smokeping/etc/config
--logfile=/opt/smokeping/log/smokeping.log

(
        while true; do
                SMOKE_SOCKET=/opt/smokeping/var/smokeping.sock
                rm -f $SMOKE_SOCKET
                FCGI_SOCKET_PATH=$SMOKE_SOCKET
/opt/smokeping/bin/smokeping_cgi &
                FPID=$!
                until [ -e $SMOKE_SOCKET ]; do
                        sleep 1;
                done;
                chgrp www /opt/smokeping/var/smokeping.sock \
                && chmod g+w /opt/smokeping/var/smokeping.sock
                wait $FPID
        done
) &
===EOF===

There are a handful of fcgi launchers in ports/pkgs that should do a
much cleaner job of it.

Hi,
Thanks for your time.
I started this topic just out of curousity and searching for a working config without sthttpd.
Here is my working config with nginx and sthttpd as a proxy:

[ns]~$ cat /etc/rc.local

# sthttpd
if [ -x /usr/local/sbin/thttpd ]; then
        echo -n ' thttpd'; /usr/local/sbin/thttpd -C /etc/thttpd.conf
fi
echo '.'

------------------------------------
nginx.conf
------------------------------------
        location ~ .*\\.(fcgi|cgi)$ {
                proxy_pass         http://127.0.0.1:8000;
                }

------------------------------------
thttpd.conf
------------------------------------
# BEWARE : No empty lines are allowed!
# This section overrides defaults
# This section _documents_ defaults in effect
# port=80
# nosymlink         # default = !chroot
# novhost
# nocgipat
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1
host=127.0.0.1
port=8000
user=www
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
dir=/var/www/
cgipat=**.cgi|**.pl|**.fcgi

Reply via email to