[PLUG] OpenWRT and http routing by host

Russell Senior russell at personaltelco.net
Sat Dec 12 01:29:06 UTC 2020


On Fri, Dec 11, 2020 at 4:05 PM Eric House <eehouse at eehouse.org> wrote:
>
> There seems to be a lot of OpenWRT expertise on this list. Having
> failed to find an answer by googling, I'm posting with crossed
> fingers.
>
> At home I run a webserver for goofing around. I've only had one domain
> hosted there and so OpenWRT needed only to forward all traffic on 80
> and 443 to the VM for that domain. Now I want to add a second domain.
> Rather than add a second server config to nginx on the VM I want
> OpenWRT to forward to a different LAN host based on the domain
> targeted by incoming http{,s} traffic.

OpenWrt is only going to see an IP address, so it doesn't know how to
port forward any differently, unless you have multiple IP addresses,
which would be unusual. I'd sink the effort into learning nginx
configuration of a second domain on the same server if I were you. Or,
as Tomas suggests, configure it to proxy to connection to a different
local server.

> [...] And given that OpenWRT doesn't seem to handle upgrades very
> well once you have non-stock packages involved I'm not confident the
> setup will remain trouble-free.

Bear in mind that OpenWrt is designed to fit into the storage space
equivalent to a handful of floppy disks, running a modern kernel and
userspace. In order to optimize the space it has, it does normally
make a lot of that storage space immutable, which makes in-place
upgrades difficult.  However, if you have a set of packages you want,
you can either build it from source, or use the ImageBuilder (I have
less experience with the latter, I tend to build whole firmwares from
source) to integrate your packages into the squashfs integrating your
own configuration, and then you can turn out your own versions as
often as you like, trading off your compile time and configuration
maintenance effort.

There are some OpenWrt tricks to building exactly what you want,
.config stubs to start from, a files overlay that gets integrated into
your firmware so it works on first boot with no post installation
twiddling.

-- 
Russell Senior
russell at personaltelco.net



More information about the PLUG mailing list