title: Rutorrent with Nginx and XMLRPC
body: <p>I'm trying to setup rutorrent on an up to date Arch Linux home server, but I can't get it running mostly I think from inexperience and also outdated documentation.</p>
  
  <h1>The problem:</h1>
  
  <p>I can't get rtorrent to talk to nxinx. When I've had rutorrent showing on nginx, it wouldn't be able to connect to rtorrent, and would give this error, among many other plugin errors:</p>
  
  <pre><code>Bad response from server: (200 [parsererror,getuisettings])
  </code></pre>
  
  <h3>Nginx's error log:</h3>
  
  <pre><code>2015/07/24 17:29:49 [error] 11837#0: *19 upstream prematurely closed connection while reading response header from upstream, client: 192.168.x.&lt;my remote machine&gt;, server: localhost, request: "GET / HTTP/1.1", upstream: "scgi://unix:/home/user/scgi.socket:", host: "192.168.x.&lt;my local nginx server&gt;"
  </code></pre>
  
  <h3>When visiting nginx's URL index:</h3>
  
  <pre><code>502 Bad Gateway
  </code></pre>
  
  <h3>In rtorrent:</h3>
  
  <pre><code>(17:50:40) Closed XMLRPC log.
  </code></pre>
  
  <h1>Config Files:</h1>
  
  <p>Here are the relevant parts of my config files:</p>
  
  <h3>.rtorrent.rc:</h3>
  
  <pre><code>#encoding_list utf-8
  scgi_local = /home/user/scgi.socket
  execute = chmod,ug=rw\,o=,/home/user/scgi.socket
  execute = chgrp,http,/home/user/scgi.socket
  #scgi_port = 127.0.0.1:5000
  </code></pre>
  
  <h3>nginx.conf:</h3>
  
  <pre><code>http {
  
  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  #tcp_nopush     on;
  #keepalive_timeout  0;
  keepalive_timeout  65;
  #gzip  on;
  
  log_format   main '$remote_addr - $remote_user [$time_local]  $status '
   '"$request" $body_bytes_sent "$http_referer" '
   '"$http_user_agent" "$http_x_forwarded_for"';
  
  access_log  /etc/nginx/logs/access.log  main;
  error_log   /etc/nginx/logs/error.log notice;
  
  server {
      listen       80;
      server_name  localhost;
      #charset koi8-r;
      location / {
          root   /usr/share/nginx/html/rutorrent;
          index  index.html index.htm;
          include scgi_params;
          scgi_pass  unix:/home/user/scgi.socket;
      }
  </code></pre>
  
  <h3>full rutorrent config.php file:</h3>
  
  <p><a href="http://pastebin.com/1tAZb6DM" rel="noreferrer">http://pastebin.com/1tAZb6DM</a></p>
  
  <p>Admittedly most of this is jargon to me. I'm familiar with rtorrent, somewhat familiar with nginx, and I know the basic theories of networking. XML, scgi/unix sockets, and php are all however beyond me (I only really know python), and I'm totally clueless as to where I would start to begin learning. I think this might have something to do with "RCP2" but I really have no idea. blog.abevoelker.com didn't have RCP2 set in nginx.conf.</p>
  
  <p>Basically be gentle with me, and I really appreciate any help you folks have to offer me. I know I'm a newbie stumbling through the dark, but I'm attempting to learn.</p>
  
  <h3>Guides used/mashed together:</h3>
  
  <p><a href="http://linoxide.com/ubuntu-how-to/setup-rtorrent-rutorrent/" rel="noreferrer">http://linoxide.com/ubuntu-how-to/setup-rtorrent-rutorrent/</a></p>
  
  <p><a href="https://blog.abevoelker.com/rtorrent_xmlrpc_over_nginx_scgi/" rel="noreferrer">https://blog.abevoelker.com/rtorrent_xmlrpc_over_nginx_scgi/</a></p>
  
  <p><a href="https://github.com/rakshasa/rtorrent/wiki/RPC-Setup-XMLRPC" rel="noreferrer">https://github.com/rakshasa/rtorrent/wiki/RPC-Setup-XMLRPC</a></p>
  
  <p><a href="https://github.com/Novik/ruTorrent/issues/974" rel="noreferrer">https://github.com/Novik/ruTorrent/issues/974</a></p>