Kodi Community Forum

Full Version: serve Kodi through Apache virtual host with only .htaccess directives
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Summary

I can't get Kodi's web server to work properly behind an Apache virtual host configured solely through a .htaccess file, and I'm wondering if anyone else has succeeded in doing this, or can offer any advice that doesn't involve modifying global Apache configuration files. More details follow.

Background

Kodi has a built-in web server for remote control, typically served on a non-standard port.

It's possible to place Kodi's web server behind an Apache virtual host, which is useful for exposing the interface on a standard port, thereby removing the need to remember the custom port number or open additional ports to the outside world. Instructions even exist on the wiki for doing exactly this, but they assume write access to Apache's global configuration files and are not tailored for a setup where .htaccess files are the only possible configuration source.

My goal

I can access Kodi's web interface internally using http://<kodi-host>:<kodi-port>, but I want to instead access it via https://kodi.my-lan.net (where "my-lan.net" is a pseudonym for a real-world domain name that points to my home LAN). I have a Synology NAS running Apache on ports 80 and 443, with both ports exposed to the outside world. Apache virtual hosts therefore seem like the answer to my goal.

My problem

My Synology NAS doesn't give me direct write access to Apache's global configuration files. I can only use .htaccess files. I'm using this one for kodi.my-lan.net:

Code:
RewriteEngine on
                                                    
# redirect all external http:// traffic to https://
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [redirect=301,last]

# proxy all requests to the Kodi box
RewriteRule ^(.*)$ http://kodi-host.my-lan.net:55555/$1 [proxy,last]

While this results in a mostly-working Kodi web interface, no movie/show images load; a 404 is returned instead for these.

The wiki instructions for this say that "[the] AllowEncodedSlashes [directive] is necessary to have webpages work properly." However, this directive isn't permitted inside a .htaccess file.

I've tried an additional RewriteRule that specifically targets image URLs with the B flag, but this didn't help, probably because it too relies on the AllowEncodedSlashes directive being enabled.

Questions
  • Can anyone suggest changes to my .htaccess file to increase my success?
  • If not, is it possible to change how Kodi's web interface requests images (i.e. without the use of slashes)?
For what it's worth, I'm running Kodi 14.2.
did you already try this?
Code:
ProxyPass / http://kodi-host.my-lan.net:55555/
ProxyPassReverse / http://kodi-host.my-lan.net:55555/
(2015-06-11, 17:07)wsnipex Wrote: [ -> ]did you already try this?
Code:
ProxyPass / http://kodi-host.my-lan.net:55555/
ProxyPassReverse / http://kodi-host.my-lan.net:55555/
ProxyPass and ProxyPassReverse directives aren't allowed in .htaccess files, unfortunately. The RewriteRule directive I've given above mostly addresses this.

I suspect that the problem I'm facing has more to do with Kodi's use of slashes in parameters of image calls.
Why don't you just simply send a redirect to the kodi port and be done with it? There is no real need to proxy it
Because I'd prefer:
  1. to be able to use the same address regardless of whether I'm accessing it from within or outside my LAN; and
  2. not to have to open yet another port on my router for external access when the technology is already there to serve it through the standard HTTP ports.