NGRProxy is an OpenWrt/LuCI app that manages nginx reverse-proxy configuration through UCI with hardened defaults, DHCP-aware upstream selection, and transactional config publishing.
- UCI-first OpenWrt model (
/etc/config/ngrproxy). - Per-host classes:
http_hostfor HTTP/TLS reverse proxies.stream_hostfor encrypted TCP passthrough (mail and similar protocols).
- Secure HTTPS upstream handling:
- requires SNI (
upstream_sni), - requires trusted CA bundle (
upstream_ca), - enforces verification for HTTPS backends.
- requires SNI (
- Upstream host dropdown populated from:
- static DHCP leases (
/etc/config/dhcp), - dynamic leases (
/tmp/dhcp.leases).
- static DHCP leases (
- LuCI preview helper with upstream URL + favicon thumbnail fallback.
- Optional screenshot thumbnail endpoint integration via LuCI controller redirect.
- Per-host ACL controls for HTTP and stream hosts.
- Optional PROXY protocol support for stream listeners/upstreams.
- Legacy config migration utility (
/usr/libexec/ngrproxy/migrate.sh). - Transactional renderer rollback if
nginx -tfails.
luci-app-ngrproxy/Makefileluci-app-ngrproxy/luasrc/controller/ngrproxy.lualuci-app-ngrproxy/luasrc/model/cbi/ngrproxy.lualuci-app-ngrproxy/root/etc/config/ngrproxyluci-app-ngrproxy/root/etc/init.d/ngrproxyluci-app-ngrproxy/root/usr/libexec/ngrproxy/migrate.shluci-app-ngrproxy/root/usr/libexec/ngrproxy/render.shluci-app-ngrproxy/root/usr/share/rpcd/acl.d/luci-app-ngrproxy.jsonscripts/run-sdk-package-tests.sh
- Add/copy
luci-app-ngrproxyinto your OpenWrt feed tree. - Run:
./scripts/feeds update -a./scripts/feeds install luci-app-ngrproxy
- Enable package in
make menuconfig. - Build and install package.
For SDK compile checks from this repository, run:
scripts/run-sdk-package-tests.sh /path/to/openwrt-sdk [more-sdk-paths...]The SDK helper installs LuCI feed dependencies, copies the app into package/feeds/luci/applications/luci-app-ngrproxy, and builds there so the package Makefile can resolve ../../luci.mk in the standard LuCI feed layout.
- Ensure nginx includes:
include /etc/nginx/conf.d/*.conf;inhttp {}include /etc/nginx/stream.d/*.conf;instream {}
- Configure hosts in LuCI and apply/reload the
ngrproxyservice. - Generated config files:
/tmp/ngrproxy/generated.http.conf/tmp/ngrproxy/generated.stream.conf
- Generated symlinks:
/etc/nginx/conf.d/zz-ngrproxy-generated.conf/etc/nginx/stream.d/zz-ngrproxy-generated.conf
- The renderer creates
/tmp/ngrproxyon first run before writing generated output. - The renderer validates the candidate config with
nginx -tand writes details to/tmp/ngrproxy.nginx-test.log. - If
nginx -tfails, NGRProxy restores the previous generated files when present, or removes newly-created generated files/symlinks when no previous files existed.
- For
http_host, enable at least one oflisten_httporlisten_https. - HTTPS listeners require
tls_certandtls_keyfiles. - HTTPS upstreams require
upstream_sniandupstream_ca; nginx upstream certificate verification remains enabled. acl_allowcan be used on HTTP and stream hosts;acl_deny_all=1denies clients not explicitly allowed.- Stream hosts can set:
listen_proxy_protocol=1to expect PROXY protocol from downstream clients/load balancers,send_proxy_protocol=1to forward PROXY metadata to upstream.
- Optional global screenshot endpoint:
- Set
settings.thumbnail_endpointwith a%splaceholder; the URL-encoded upstream URL is substituted.
- Set
Legacy migration is intentionally conservative:
/usr/libexec/ngrproxy/migrate.shconverts legacyhost/proxysections intohttp_hostsections.- The service runs migration during
start_service()only whensettings.enabled=1. - Migration is guarded by
/etc/ngrproxy/.migrated-v1to avoid repeated rewrites. - If you need migration before enabling the service, run
/usr/libexec/ngrproxy/migrate.shmanually on the router, then review and commit UCI state as needed.