Posted by virantha on Sat 08 March 2014

Pound reverse proxy and simpler URLs for webapps (Sickbeard, Plex, CouchPotato, Headphones, SABNZBD)

I run a plethora of local web applications that each listen on different ports, and I wanted to simplify their URLs so I could just type a hostname to access them:

Hostname mapping
Application Default URL Desired URL
Sickbeard http://linux-server:8081 http://sickbeard
SabNZBD http://linux-server:8080 http://sabnzbd
Nagios http://fw:1008/nagios http://nagios
Plex Media Server http://media-server:32400/web http://plex

Turns out, this is really simple to do by installing Pound, but it took me some time to piece together how to configure it for Plex and Nagios, which have both a port number and a path mapping. Basically, the recipe is that you first redirect the URL path portion, and then you do the host/port redirect. Plex has an additional issue with some javascript in the web interface that causes a loop unless you put in a rule to detect a particular header text (X-Plex-Device-Name) to avoid remapping the /web portion of the URL.

Here's my pound.cfg configuration file for future reference (obviously, this requires that you've set up your DNS/hosts to point all the aliases like sickbeard, plex, etc. to whatever host is running pound)

ListenHTTP
        Address 192.168.9.1
        Port 80
        Service
                HeadRequire "Host: .*sickbeard.*"
                BackEnd
                        Address linux-server
                        Port 8081
                End
        End
        Service
                HeadRequire "Host: .*sabnzbd.*"
                BackEnd
                        Address linux-server
                        Port 8080
                End
        End
        Service
                HeadRequire "Host: .*couchpotato.*"
                BackEnd
                        Address linux-server
                        Port 5050
                End
        End
        Service
                HeadRequire "Host: .*headphones.*"
                BackEnd
                        Address linux-server
                        Port 8181
                End
        End

        # Following two services for plex
        Service
                HeadRequire "Host: .*plex.*"
                HeadDeny "X-Plex-Device-Name"
                URL "^/$"
                Redirect "http://plex/web"
        End
        Service
                HeadRequire "Host: .*plex.*"
                BackEnd
                        Address media-server
                        Port 32400
                End
        End

        # NAGIOS
        Service
                HeadRequire "Host: .*nagios.*"
                URL "^/$"
                Redirect "http://nagios/nagios"
        End
        Service
                HeadRequire "Host: .*nagios.*"
                BackEnd
                        Address fw
                        Port 1008
                End
        End

End

© Virantha Ekanayake. Built using Pelican. Modified svbhack theme, based on theme by Carey Metcalfe