Reverse proxying Sabnzbd, Couchpotato, Sickbeard & Headphones with Nginx

Sabnzbd, Couchpotato, Sickbeard and Headphones are great applications to automate downloading of movies, TV-shows and music. They are all written in Python and feature a build in webserver which is accessible from localhost on various ports. Because I’m running these programs on my Ubuntu Minimal installation with XBMC as only frontend, I can’t browse locally to them. Since I find it much easier to memorize a domain name instead of port numbers, I’ve set up a reverse proxy server with Nginx.

How to install?

Install Nginx with your favorite package manager like aptitude, put the files beneath in /etc/nginx/sites-available/ and symlink to /etc/nginx/sites-enabled/ to enable them. On your local machine (in /etc/hosts) or local DNS server add sabnzbd.local, couchpotato.local, sickbeard.local and headphones.local pointing to the ip address of your download server.

Sabnzbd

upstream sabnzbd  {
  server localhost:8080;
}

server {
  server_name  sabnzbd.local;

  location / {
    proxy_pass  http://sabnzbd;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Couchpotato

upstream couchpotato  {
  server localhost:5050;
}

server {
  server_name  couchpotato.local;

  location / {
    proxy_pass  http://couchpotato;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Sickbeard

upstream sickbeard  {
  server localhost:8081;
}

server {
  server_name  sickbeard.local;

  location / {
    proxy_pass  http://sickbeard;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Headphones

upstream headphones  {
  server localhost:8181;
}

server {
  server_name  headphones.local;

  location / {
    proxy_pass  http://headphones;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
comments powered by Disqus