Skip to content

Using XBMC Video Server through a reverse proxy

Sam Stenvall edited this page Nov 22, 2015 · 4 revisions

NOTE! This is not the same as configuring a reverse proxy for XBMC itself, this is about accessing XBMC Video Server through a separate web server.

Background

Reverse proxying is the process of making your application available from another web server, like in the following example:

http://example.com/media is a proxy for http://internal.example.com/xbmc-video-server/src

This guide is only for the Apache web server. If you want to do the proxying with Nginx you're on your own.

Requirements

You'll need to have proxy_http and proxy_html addons in Apache:

Linux

If you are using the Debian packaging system (Debian and Ubuntu derivatives do) you can run the following commands:

sudo apt-get install libapache2-mod-proxy-html
sudo a2enmod proxy_http proxy_html

Mac OS X

If you have MacPorts or Brew you can use your those to install mod_proxy_html and follow up with the same a2enmod command as above. If you do not have MacPorts or Brew you can do it manually.

Download mod_proxy_html from here.
Unpackage then run the files then do the following commands:

sudo apxs -ci -I /usr/include/libxml2 mod_xml2enc.c
sudo apxs -ci -I /usr/include/libxml2 -I . mod_proxy_html.c

Update the httpd.conf file (commonly located at /etc/apache2/)

LoadFile /usr/lib/libxml2.dylib
LoadModule	proxy_html_module	libexec/apache2/mod_proxy_html.so
LoadModule	xml2enc_module	libexec/apache2/mod_xml2enc.so

Setup

Here's an example configuration site configuration file for Apache. It has only been tested on Apache 2.2 (Debian Wheezy) and may need some modifications for Apache 2.4. In this example, http://xbmc-video-server.example.com/media is a proxy for http://localhost/xbmc-video-server/src.

<VirtualHost *:80>

        ServerName xbmc-video-server.example.com

        # do the actual proxying
        ProxyPass        /media http://localhost/xbmc-video-server/src
        ProxyPassReverse /media http://localhost/xbmc-video-server/src

        # decompress so we can modify the contents
        SetOutputFilter INFLATE;proxy-html;DEFLATE

        # you may need to uncomment this line with Apache 2.4
        #ProxyHTMLEnable On

        # make sure Apache doesn't try to "fix" the DOCTYPE
        ProxyHTMLDocType "<!DOCTYPE html>"

        # these directives need to be duplicated since we're in a
        # different scope. We actually only want to add "img data-src"
        ProxyHTMLLinks  a               href
        ProxyHTMLLinks  area            href
        ProxyHTMLLinks  link            href
        ProxyHTMLLinks  img             src longdesc usemap data-src
        ProxyHTMLLinks  object          classid codebase data usemap
        ProxyHTMLLinks  q               cite
        ProxyHTMLLinks  blockquote      cite
        ProxyHTMLLinks  ins             cite
        ProxyHTMLLinks  del             cite
        ProxyHTMLLinks  form            action
        ProxyHTMLLinks  input           src usemap
        ProxyHTMLLinks  head            profile
        ProxyHTMLLinks  base            href
        ProxyHTMLLinks  script          src for

        # finally, rewrite URLs
        ProxyHTMLURLMap /xbmc-video-server/src/ /media/

</VirtualHost>