Emil Miler

Connecting Kodi to Nginx media index

Connecting Kodi to network media storage can be cumbersome to setup, especially with NFS. This setup uses simple HTTP and Nginx instead.

Assuming that Kodi is installed and connected to our network and we have a server with Nginx. We just need to expose our media storage with auto-indexing enabled. This might seem insecure, but we are only exposing things to our internal trusted network. Never let any untrusted devices into your subnet – which should go without saying.

Nginx

I am using Nginx as a reverse proxy to other services and media directories, so I have to deal with different locations. Simple configuration could look like this.

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	server_name server.local 192.168.1.10;
	root /srv/www/default;
	index index.html;

	charset UTF-8;

	location / {
		try_files $uri $uri/ =404;
	}

	location /films {
		alias /srv/media/films;
		autoindex on;
	}

	location /shows {
		alias /srv/media/shows;
		autoindex on;
	}
}

Make sure to set charset UTF-8; to enable special characters. I use both mDNS server.local and IP address for VPN access and because Alpine clients do not support mDNS address resolution due to musl limitations.

After reloading Nginx, the file index should be available at both:

Kodi

We can now add a new share in Kodi and select a custom network location, which lets us choose from many different protocols.

Simply select HTTP, set your server address and set the remote path to the desired endpoint. The address can be the mDNS hostname, if your client supports address resolution.

Conclusion

That’s it, extremely simple and read-only media share. I recommend managing your library with something that can generate movie.nfo for each film – for example Radarr – and turn off metadata fetching from the Internet. Parsing files and other metadata – including images – will be quite snappy.

2022-10-19, Emil Miler