Skip to content

Instantly share code, notes, and snippets.

@ynezz
Last active October 15, 2022 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynezz/47f559af730a2bbc77f1f15b3921f8e7 to your computer and use it in GitHub Desktop.
Save ynezz/47f559af730a2bbc77f1f15b3921f8e7 to your computer and use it in GitHub Desktop.
prpl-webui container proxied demo

prpl-webui demo with proxied TR-181 REST API

image

This demo uses slim prplOS based prpl-webui-testing-container-x86-64 container which serves only upcoming prplOS reference prpl-webui web UI and otherwise it's using TR181 REST API from the host.

Requests to TR-181 REST API /serviceElements endpoint are being proxied to host TR-181 REST API endpoint on http://192.168.1.1:8080 backend server and can be changed in /etc/lighttpd/conf.d/50-prplos-auth.conf file if needed be:

$HTTP["url"] =~ "^/serviceElements" {
        proxy.server = ( "" => ( ("host"=>"192.168.1.1","port" => "8080" ) ) )
}

How to configure prplOS with prpl-webui container

1. Start prpl-webui container

Following ubus-cli can be used to start the container:

  • Cthulhu.Config.DhcpCommand="udhcpc -r 192.168.1.200 -i"
  • Cthulhu.Sandbox.Instances.1.NetworkNS.Type="Veth"
  • Cthulhu.Sandbox.Instances.1.NetworkNS.Interfaces.+{Bridge="br-lan",Interface="eth0",EnableDhcp=1}'
  • Cthulhu.Sandbox.Instances.1.NetworkNS.Enable=1
  • Cthulhu.Sandbox.start(SandboxId="generic")
  • SoftwareModules.InstallDU(URL="docker://registry.gitlab.com/prpl-foundation/prplos/prplos/prpl-webui-testing-container-x86-64", UUID="prplos-testing", ExecutionEnvRef="generic")

2. Fine tune host for seamless UX

2.1 Disable REST API authentication protection

prpl-webui is work in progress, so authentication is not implemented yet and thus it needs to be disabled.

sed -i '9,$d' /etc/lighttpd/conf.d/50-prplos-auth.conf 
/etc/init.d/lighttpd restart

2.2 Setup LAN port forwarding

Makes web UI available on the host from LAN on port 8081.

container_ip=$(/opt/prplos/usr/bin/lxc-info -iH prplos-testing) 
iptables -A PREROUTING -t nat -i br-lan -p tcp --dport 8081 -j DNAT --to ${container_ip}:8080 
iptables -A INPUT -i br-lan -p tcp --dport 8081 -j ACCEPT 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment