Sunday, May 25, 2025

How configure reverse proxy for Kodi web interface (chorus2)

 This tutorial goes over the steps to configure chorus2 behind nginx reverse proxy so you can remotely control your Kodi setup.

First Enable Kodi Web Interface and set a username and password in the settings as explained here

Then you can launch kodi web interface on Chromium and in the settings enable reverseproxy setup and also configure the port for your reverse proxy which usually is 443 for your nginx SSL.


For our nginx configuration, we need to note the following point in nginx reverse proxy docs:

A request URI is passed to the server as follows:

  • If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:
    location /name/ {
        proxy_pass http://127.0.0.1/remote/;
    }
    
  • If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:
    location /some/path/ {
        proxy_pass http://127.0.0.1;
    }
    
    Before version 1.1.12, if proxy_pass is specified without a URI, the original request URI might be passed instead of the changed URI in some cases.

Otherwise the way that kodi web interface tries to load images will not work.


## Kodi rewrite

# 1) WS for /jsonrpc (no prefix)
location ^~ /jsonrpc {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 360s;

proxy_pass http://10.10.1.5:9090;
}

# 2) Redirect bare /kodi → /kodi/
location = /kodi {
return 301 /kodi/;
}
# 3) Everything else under /kodi/ → strip prefix
location /kodi/ {
if ($request_uri ~ "^/kodi(?<after>/[^?]*)") {
set $new_path $after;
}

proxy_cache off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 300s;

proxy_pass http://10.10.1.5:10080$new_path$is_args$args;
}

####


 

Friday, April 18, 2025

How to Compile the Latest wf‑recorder on Raspberry Pi 5 (Debian 12 Wayland)

Debian 12 on Raspberry Pi 5 uses Wayland, so x11grab won’t work for screen capture. You can switch to wf-recorder, but the stock v0.3 in Debian’s repositories lacks newer flags like --overwrite

To get the latest wf-recorder with full feature support, you’ll need to build it from source. Here’s how:


# Install dependencies

sudo apt install g++ meson libavutil-dev libavcodec-dev libavformat-dev libswscale-dev libpulse-dev wayland-protocols libpipewire-0.3-dev

mkdir ~/src

cd ~/src

https://github.com/ammen99/wf-recorder/releases

wget https://github.com/ammen99/wf-recorder/releases/download/v0.5.0/wf-recorder-0.5.0.tar.xz

tar -xf wf-recorder-0.5.0.tar.xz

cd wf-recorder-0.5.0

meson setup build --prefix=/usr --buildtype=release --reconfigure

ninja -C build

# Install

cp ~/src/wf-recorder-0.5.0/build/wf-recorder /usr/local/bin


Now you can record the screen including audio using the following command:


wf-recorder --overwrite -a default -f file.mp4

Friday, February 21, 2025

How to set up Kodi with YouTube addon on Raspberry OS Debian 12

 In this post, we review how to run Kodi with Kodi Youtube Addon on Raspberry Pi 5. 

There are two versions of Kodi available on Raspberry Pi OS for Debain 12. `kodi` package installs v20.0 and `kodi21` installs version 21. Make sure to use v21 as it has resolved some bugs that causes glitches in video playback,

# Install Kodi21 

apt-get install kodi21 kodi21-inputstream-adaptive

# Download Kodi Youtube Plugin Repository 

cd /home/pi/Downloads

wget https://ftp.fau.de/osmc/osmc/download/dev/anxdpanic/repositories/repository.yt.testing_unofficial-2.0.7.zip

# Open Kodi -> Settings -> Addon -> Install from Zip File -> Home Folder -> Downloads -> Select the above zip file that you downloaded

#  Go Back (Settings -> Addon) -> Options (at bottom left) -> Check for Updates 

# Go Back (Settings -> Addon) -> Install from Repository -> Youtube Test Repo (Unofficial) -> Video add-ons -> Youtube -> Install

# add a Youtube API v3 API has described here. Just note that Publishing status in Audience should be Production. In Data Access section you need to enable Youtube related permissions. It will ask to login two times when trying to login on Youtube Addon for Kodi, and on your google device will show a warning that the app is not verified as explained here

#  Go to Home page -> Youtube -> Add-on settings (left side) -> API: fill API Key, API Id and API Secret by your Youtube API

# You can set Proxy setting in Kodi -> Setting -> System -> Internet Access

# Kodi turns on TV when it is started, and turns off TV when exitted. The behaviour can be set up in Kodi -> Setting -> System -> Interface

# To avoid your raspberry pi turning on your TV when it is rebooted, add hdmi_ignore_cec_init=1 to /boot/firmware/config.txt

# PartyMode addon can be used to set youtube addon to start up automatically when running Kodi

# piflare.com service can be used to connect raspberry pi to telegram so it starts kodi by running /youtube command


/scripts/youtube.py :

#!/home/pi/python/bin/python3

import os, sys, time

os.chdir('/home/pi')


os.environ["DISPLAY"] = ":0"

os.environ["WAYLAND_DISPLAY"] = "wayland-0"

os.environ["XDG_RUNTIME_DIR"] = "/run/user/1000"

os.environ["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=/run/user/1000/bus"


os.system("pkill -9 -f 'chrome|chromium|google-chrome|chrome_crashpad_handler|kodi|kodi21.bin'")

os.system('/usr/bin/kodi &')

How configure reverse proxy for Kodi web interface (chorus2)

 This tutorial goes over the steps to configure chorus2 behind nginx reverse proxy so you can remotely control your Kodi setup. First Enabl...