:: Setup XFileSharing on NGINX

1 min read

:: How to setup XFileSharing with NGINX
+ installing and setup fcgiwrap for nginx

wget //github.com/gnosek/fcgiwrap/tarball/master
tar -xzf master
cd gnosek-fcgiwrap-1328862
autoreconf -i
./configure
make
make install

+ create fastcgi socket

vi fastcgisock.pl

add these line:

#!/usr/bin/perl

use strict;
use warnings FATAL => qw( all );

use IO::Socket::UNIX;

my $bin_path = '/usr/local/bin/fcgiwrap';
my $socket_path = $ARGV[0] || '/tmp/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";
} 

run the script

chmod +x fastcgisock.pl
./fastcgisock.pl

+ setup XFileSharing on NGINX

vi /etc/nginx/vhost/blackonsole.org.conf

add these line:

server {
        listen 80;
        server_name wwww.blackonsole.org;

        error_log /var/log/nginx/blackonsole.org-error.log;

        location / {
                root /home/vhost/blackonsole.org/htdocs;
                index  index.cgi index.html index.htm;

                if (!-f $request_filename) {
                        rewrite "^/([0-9A-Za-z]{12})(/.+|.html?|$)"       /cgi-bin/index_dl.cgi?op=download1&id=$1&fname=$2 last;
                }

                rewrite "^/embed-([0-9A-Za-z]{12}).html$"          /cgi-bin/index_dl.cgi?op=video_embed&file_code=$1 last;
                rewrite "^/embed-([0-9A-Za-z]{12})-(d+)x(d+).html$"              /cgi-bin/index_dl.cgi?op=video_embed&file_code=$1&w=$2&h=$3 last;
                rewrite "^/embedmp3-([0-9A-Za-z]{12}).html$"       /cgi-bin/index_dl.cgi?op=mp3_embed&file_code=$1 last;
                rewrite "^/mp3embed-([0-9A-Za-z]{12}).mp3$"        /cgi-bin/index_dl.cgi?op=mp3_embed2&file_code=$1 last;
                rewrite "^/vidembed-([0-9A-Za-z]{12})"              /cgi-bin/index_dl.cgi?op=video_embed2&file_code=$1 last;

                rewrite ^/box$  /cgi-bin/index.cgi last;

                rewrite ^/$      /cgi-bin/index.cgi last;
                rewrite ^/free([0-9]+).html$                     /cgi-bin/index.cgi?op=registration&aff_id=$1 last;
                rewrite ^/checkfiles.html$                       /cgi-bin/index.cgi?op=checkfiles last;
                rewrite ^/contact.html$                          /cgi-bin/index.cgi?op=contact last;
                rewrite ^/premium.html$                          /cgi-bin/index.cgi?op=payments last;
                rewrite ^/login.html$                            /cgi-bin/index.cgi?op=login last;
                rewrite ^/catalogue(.*).html$                    /cgi-bin/index.cgi?op=catalogue&date=$1 last;
                rewrite ^/news([0-9]*).html$                     /cgi-bin/index.cgi?op=news&page=$1 last;
                rewrite ^/n([0-9]+)-.*.html$                     /cgi-bin/index.cgi?op=news_details&news_id=$1 last;
                rewrite ^/faq.html$                              /cgi-bin/index.cgi?op=page&tmpl=faq last;
                rewrite ^/tos.html$                              /cgi-bin/index.cgi?op=page&tmpl=tos last;
                rewrite ^/links.html$                            /cgi-bin/index.cgi?op=links last;


                if ( !-f $request_filename) {
                        rewrite ^/pages/([a-z0-9-_]+).html  /cgi-bin/index.cgi?op=page&tmpl=$1$2 last;
                }

                if (!-e $request_filename) {
                        rewrite "^/users/([0-9A-Za-z-_]{4,64})/?([0-9]+|$)" /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld_id=$2 last;
                }

                rewrite .pm$ /404.html last;


        }

        location ~ ^/cgi-bin/.*.cgi$ {
                gzip off;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/tmp/cgi.sock;
                fastcgi_index index.cgi;
                fastcgi_param SCRIPT_FILENAME /home/vhost/blackonsole.org/htdocs$fastcgi_script_name;
        }

}

+ testing configure file and reload nginx

nginx -t
nginx -s reload

+ installing XFileSharing
make sure your cgi-bin under htdocs folder, then install XFileSharing via web browser.

 
:: Links
+ Google
+ SibSoft

How to install NextCloud in Ubuntu 22.04

What’s NextCloud Nextcloud is an open-source software suite that offers a secure, self-hosted alternative to popular cloud storage and productivity platforms. With a focus...
sysadmin.id
8 min read

Reset root password on CentOS 7

Edit boot menu on-the-go 0. reboot the CentOS 7 and press ESC when GRUB menu show up on the screen and press “e” 1....
sysadmin.id
18 sec read

Free ext4 reserved blocks with tune2fs

Check disk usage df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 95G 82G 7.9G 92% / Check size of Reserved block count...
sysadmin.id
19 sec read