rutorrent/PHP/Nginx issues

dsouvik215

Member
May 25, 2018
896
0
16
I've been working on getting my home "seedbox" setup over the past day or two. For various reasons I'm not using one of the popular seedbox setup scripts; mostly because I like to avoid magic and I enjoy learning.

So far I've managed to successfully configured rtorrent (more or less, some finishing touches are to come) and I have it starting at boot using cron. I've setup Sick Beard, and CouchPotato. They even have proper init scrips so they start on boot like proper daemons. I have Nginx up and running. And rutorrent is at least opening when I browse to it.

The main problem that I'm having is somewhere in my Nginx/PHP/rutorrent config. When I open http://seedbox.local/rutorrent I am greeted by a proper rutorrent page but I am seeing an error in the log:

Code: [Select]
[28.03.2014 20:48:20] Bad response from server: (405 [error,list]) <html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.4.7</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

As best I can tell this is due to a PHP misconfiguration but for the life of me I can't figure out what I'm missing. If anyone more familiar with PHP could give me some idea what I'm doing wrong I would greatly

/etc/nginx/nginx.conf:
Code: [Select]
user www-data;
worker_processes 1;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-available/rutorrent:
Code:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6

root /usr/share/nginx/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

/usr/share/nginx/html/rutorrent/conf/config.php:
Code:
<?php
// configuration parameters

// for snoopy client
@define('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0', true);
@define('HTTP_TIME_OUT', 30, true); // in seconds
@define('HTTP_USE_GZIP', true, true);
$httpIP = null; // IP string. Or null for any.

@define('RPC_TIME_OUT', 5, true); // in seconds

@define('LOG_RPC_CALLS', false, true);
@define('LOG_RPC_FAULTS', true, true);

// for php
@define('PHP_USE_GZIP', false, true);
@define('PHP_GZIP_LEVEL', 2, true);

$schedule_rand = 10; // rand for schedulers start, +0..X seconds

$do_diagnostic = true;
$log_file = '/tmp/errors.log'; // path to log file (comment or leave blank to disable logging)

$saveUploadedTorrents = true; // Save uploaded torrents to profile/torrents directory or not
$overwriteUploadedTorrents = false; // Overwrite existing uploaded torrents in profile/torrents directory or make unique name

$topDirectory = '/'; // Upper available directory. Absolute path with trail slash.
$forbidUserSettings = false;

$scgi_port = 5000;
$scgi_host = "127.0.0.1";

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
// $scgi_port = 0;
// $scgi_host = "unix:///tmp/rpc.socket";

$XMLRPCMountPoint = "/RPC2"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

$pathToExternals = array(
"php" => '', // Something like /usr/bin/php. If empty, will be found in PATH.
"curl" => '', // Something like /usr/bin/curl. If empty, will be found in PATH.
"gzip" => '', // Something like /usr/bin/gzip. If empty, will be found in PATH.
"id" => '', // Something like /usr/bin/id. If empty, will be found in PATH.
"stat" => '', // Something like /usr/bin/stat. If empty, will be found in PATH.
);

$localhosts = array( // list of local interfaces
"127.0.0.1",
"localhost",
);

$profilePath = '../share'; // Path to user profiles
$profileMask = 0777; // Mask for files and directory creation in user profiles.
// Both Webserver and rtorrent users must have read-write access to it.
// For example, if Webserver and rtorrent users are in the same group then the value may be 0770.

$tempDirectory = null; // Temp directory. Absolute path with trail slash. If null, then autodetect will be used.
/etc/php5/fpm/php-fpm.conf:
Code:
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /run/php5-fpm.pid

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf

/home/rtorrent/.rtorrent.rc
Code:
# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50

# Maximum number of simultanious uploads per torrent.
#max_uploads = 15

# Global upload and download rate in KiB. "0" for unlimited.
#download_rate = 0
#upload_rate = 0

# Default directory to save the downloaded torrents.
#directory = ./

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = /home/rtorrent/.session

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
#schedule = low_diskspace,5,60,close_low_diskspace=100M

# Port range to use for listening.
#port_range = 6890-6999

scgi_port = 127.0.0.1:5000

encryption = require,require_RC4,allow_incoming,try_outgoing,enable_retry
My logs don't contain anything to interesting.

Nginx's error log has a few of these in it:

2014/03/28 19:17:14 [error] 4579#0: *20 FastCGI sent in stderr: "PHP message: PHP Warning: fopen(/usr/share/nginx/html/rutorrent/share/users/adam/settings/uisettings.json): failed to open stream: No such file or directory in /usr/share/nginx/html/rutorrent/php/getsettings.php on line 7" while reading response header from upstream, client: 192.168.1.101, server: _, request: "POST /rutorrent/php/getsettings.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "seedbox", referrer: "http://seedbox/rutorrent/"

The php5-fpm log is even less interesting:

[28-Mar-2014 18:58:37] NOTICE: fpm is running, pid 4042
[28-Mar-2014 18:58:37] NOTICE: ready to handle connections
[28-Mar-2014 18:58:37] NOTICE: systemd monitor interval set to 10000ms
[28-Mar-2014 19:09:51] NOTICE: Finishing ...
[28-Mar-2014 19:09:51] NOTICE: exiting, bye-bye!
[28-Mar-2014 19:10:53] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful