Raspi: nginx + rtmp

Hi there,

I'm new to Open WRT and find it quite cool. However I need some help setting up my raspi so it does what it should. So far the Access point works fine but obviously I need more :smiley:

My use case: use the Raspi as a RTMP Streaming-Device to stream live drone footage to a tablet.

As said, the access point now works fine, but I have problems setting up nginx let alone it using rtmp. On Raspian this worked fine for me: https://www.itsfullofstars.de/2020/01/nginx-with-rtmp-on-raspberry-pi-as-a-streaming-server-for-obs/
Problems are:

  • Uci is interfering with port 80 (how do I change that?)
  • Also where/how do I modify the conf file for nginx to use rtmp?

Looking foward to any advice.

Thanks :slight_smile:

Is there an RTMP nginx module for OpenWrt?

The website you linked says Debian.

Actually the conflict is the default tiny web server uhttpd, which serves the LuCI pages. Options are to remove uhttpd or edit /etc/config/uhttpd to listen on a different port. nginx should serve LuCI if you still want LuCI.

There is an nginx-all-module package which may include the module you need.

2 Likes

Thanks a lot so far :slight_smile:
I disabled uhttpd via /etc/init.d/uhttpd disable
Next I enabled nginix via /etc/init.d/nginx enable

In the /etc/nginx/nginx.conf I added this include to the (on raspianOs working) config
include /etc/nginx/rtmp.conf;

Here's the content of the rtmp.conf:

rtmp {
  server {
    listen 1935;
    chunk_size 4096;
    application live {
      live on;
      record off;
    }
  }
}

After a reboot the services are running as configured. However, when I try to connect to the RTMP either for streaming or receiving, I get an error message saying I can't connect :frowning: My guesses are.

  • some misconfig in the nginix configurations
  • maybe some firewall issue on OpenWrt? How can I check that port 1935 isn't blocked?

Also, can someone enlighten me on the difference between these two config-files:
/etc/config/nginx and /etc/nginx/nginx.conf It's kind of confusing :see_no_evil:

Thanks a lot so far :slight_smile:

Hm, good point: Looks like there isn't a "real" package

root@OpenWrt:~# opkg install nginx-rtmp
Unknown package 'nginx-rtmp'.
Collected errors:
 * opkg_install_cmd: Cannot install package nginx-rtmp.

However I found this: https://github.com/openwrt/packages/blob/master/net/nginx/Makefile that has several mentions of rtmp in it

define Download/nginx-rtmp
  VERSION:=f0ea62342a4eca504b311cd5df910d026c3ea4cf
  SUBDIR:=nginx-rtmp
  FILE:=ngx-rtmp-module-$$(VERSION).tar.xz
  URL:=https://github.com/ut0mt8/nginx-rtmp-module.git
  MIRROR_HASH:=d3f58066f0f858ed79f7f2b0c9b89de2ccc512c94ab3d0625f6dcff3df0b72c1
  PROTO:=git
endef

define Prepare/nginx-rtmp
	$(eval $(Download/nginx-rtmp))
	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
endef

Do you have any advice how to get this on my raspi with OpenWRT and working? :slight_smile:

/etc/config/nginx is an OpenWrt extension intended to help configure nginx for most basic and common use cases. If you're working from an example which is pure nginx config, basically you don't want to use the UCI system. Reduce /etc/config/nginx to this:

config main global
	option uci_enable 'false'

and configure nginx conventionally with files in /etc/nginx.

1 Like

Cool. Thanks! :slight_smile:

Now how do I compile the nginix-package located in Git on my Raspi so I have the RTMP-module?