XBMC default web interface not working behind reverse proxy => should I share my fix?
#1
Question 
Hi,

I am not really sure I should file a bug report for this, so checking here for opinion. I have a fix available, but I might be the only person in the world doing that, so...

My PC with XBMC runs several HTTP services who have their own webserver. I made all of them accessible to the outside world through a reverse proxy in HTTPS (i.e a single host which forwards requests to one server or the other based on the URL. For example https://myproxy/xbmc/index is forwarded to /index on the xbmc server on port 8080.)

What I noticed is that the default XBMC web interface had several non-relative folders, which I had to hack to get the whole thing working. I think my changes are correct since not only the reverse proxy access works, but also the direct access.

Also, I noticed that the jsonrpc calls are hard-coded to an absolute URL "/jasonrpc" which requires a bit of "dirty work" in the reverse proxy configuration.

I can share my changes for a patch. For the "/jsonrpc" hard-coded url, I could open a bug report or document my reverse proxy configuration (as it works even if it is not clean).

Is there any interest besides myself?

V.
Reply
#2
Yes, Please share if you could. I am also trying to get this to work via reverse proxy.
Reply
#3
Ok, so here is what I have (I'm running on Ubuntu, your paths may of course vary) if I remember correctly

1. Enable the proper apache modules (In my case I used proxy_http and mod_proxy)
2. allow URL revwriting/proxying in your apache file (/etc/apache2/sites-enabled/default-ssl)
Code:
    ProxyPass /xbmc/ http://localhost:8080/
    ProxyPassReverse http://localhost:8080/ /xbmc/
    ProxyPass /xbmc/jsonrpc http://localhost:8080/jsonrpc
    ProxyPassReverse http://localhost:8080/jsonrpc /xbmc/jsonrpc
3. Correct the web addon (often they use non-relative URLs). For example if you look at /usr/share/xbmc/addons/webinterface.default/index.html, you see things like (I put everything in one shot hee, but those lines are scattered all around the file)
Code:
<link rel="icon" href="[color=red]/[/color]favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="[color=red]/[/color]favicon.ico" type="image/x-icon">
<link href="[color=red]/[/color]css/core.css?1.3.57" rel="stylesheet" type="text/css">
<link href="[color=red]/[/color]css/ipad.css?1.0.5" rel="stylesheet" media="only screen and (max-device-width: 1024px)" type="text/css">
<script type="text/javascript" src="[color=red]/[/color]js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="[color=red]/[/color]js/Launcher.js?1.0.0"></script>
<img src="[color=red]/[/color]images/ajax-loader.gif" alt="Loading please wait" id="spinner" style="display: none">


This should be all replaced with relative URLs:
Code:
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link href="css/core.css?1.3.57" rel="stylesheet" type="text/css">
<link href="css/ipad.css?1.0.5" rel="stylesheet" media="only screen and (max-device-width: 1024px)" type="text/css">
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/Launcher.js?1.0.0"></script>
<img src="images/ajax-loader.gif" alt="Loading please wait" id="spinner" style="display: none">

This line must be edited as well in /usr/share/xbmc/addons/webinterface.default/js/Core.js
From
Code:
var JSON_RPC = '/jsonrpc';
To
Code:
var JSON_RPC = 'jsonrpc';

Let me know if that helps.

V.
Reply
#4
You should be able to make it work without changing the web interface code. ProxyHTMLURLMap in Apache can help.
Reply
#5
Zeron Wrote:You should be able to make it work without changing the web interface code. ProxyHTMLURLMap in Apache can help.
To be honest, I did not know this one, so I did not try. Even if this should prevent editing the HTML files as above, I am not sure however this will rewrite links dynamically built in Javascript (see Core.js above).

If somebody gives it a try, it would ne interesting to feedback their result in this thread.

V.
Reply
#6
Zeron Wrote:You should be able to make it work without changing the web interface code. ProxyHTMLURLMap in Apache can help.

Sorry to bring up an old thread... I would really like some help achieving this as I'm trying to get a bit familiar with apache2, so far I've got sabnzbd+, sick sickbeard, and couchpotato all behind a reverse proxy I want to put xbmc behind one also but i can't seem to get it to work.

Can anyone help??
Reply
#7
Anyone knows whether this will be fixed in Frodo release? I am running Eden and the issue is still there. Also, not clear to me (even with the description above) how to fix the issue.
Server: Asus Sabertooth Z77 | Intel Core i5 3.4 GHz | 16 GB DDR3 | 128 GB SSD, 82 TB (9 x 6 TB, 7 x 4 TB)
HTPC 1: Raspberry Pi 2 | HTPC 2: Raspberry Pi 2 | HTPC 3: Raspberry Pi
Reply
#8
I just pushed https://github.com/xbmc/xbmc/commit/6b20...531b0a9578 which makes all paths in the webinterface relative. I can't test if it solves the reverse proxy problem because I don't operate one but using relative paths is better anyway.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#9
(2012-08-03, 16:34)Montellese Wrote: I just pushed https://github.com/xbmc/xbmc/commit/6b20...531b0a9578 which makes all paths in the webinterface relative. I can't test if it solves the reverse proxy problem because I don't operate one but using relative paths is better anyway.

I just tried this but I needed to modify some of the js files too for /image*

MediaLibrary.js
NowPlayingManager.js

Can you update these also.

Thanks,
Neil
Reply
#10
Thanks for letting me know. Fixed in https://github.com/xbmc/xbmc/commit/a058...edaeb19c4a
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#11
Perfect, Thanks.
Reply
#12
(2012-08-12, 15:53)Montellese Wrote: Thanks for letting me know. Fixed in https://github.com/xbmc/xbmc/commit/a058...edaeb19c4a

I am using the August monthly of pre-Frodo and it is still not working. Anyone has success with it?
Server: Asus Sabertooth Z77 | Intel Core i5 3.4 GHz | 16 GB DDR3 | 128 GB SSD, 82 TB (9 x 6 TB, 7 x 4 TB)
HTPC 1: Raspberry Pi 2 | HTPC 2: Raspberry Pi 2 | HTPC 3: Raspberry Pi
Reply
#13
Just tried it and it is somewhat fixed. I can access web interface now over reverse proxies. Still having issues with the JSONRPC though. Please see below:

My settings:

<Location /xbmc/>
ProxyPass http://192.168.1.105:8080/
ProxyPassReverse http://192.168.1.105:8080/
</Location>

<Location /xbmc/jsonrpc>
ProxyPass http://192.168.1.105:8080/jsonrpc
ProxyPassReverse http://192.168.1.105:8080/jsonrpc
</Location>


Using this, xbmc is accessible when accessing my-URL/xbmc. When trying to access jsonrpc, I get the following message, which doesn't look bad, but is different from when accessing directly without reverse proxies:

<html><head><title>JSONRPC</title></head><body>JSONRPC active and working</body></html>
Server: Asus Sabertooth Z77 | Intel Core i5 3.4 GHz | 16 GB DDR3 | 128 GB SSD, 82 TB (9 x 6 TB, 7 x 4 TB)
HTPC 1: Raspberry Pi 2 | HTPC 2: Raspberry Pi 2 | HTPC 3: Raspberry Pi
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC default web interface not working behind reverse proxy => should I share my fix?0