Danel installs Homebox on his home network.
Daniel installs it on an Ubuntu VM at 10.0.0.1.
Daniel later realises that his home network config is dumb! He moves the gateway to 10.0.0.1.
Daniel also buys a URL / FQDN for his Homebox instance and uses Cloudflare Tunnel to route to it.
But Daniel now has a problem!
He has thousands of barcodes and QR codes in his house. They all look like this:
10.0.0.1:3100/item/daniels-tech-thing
Daniel knows that ther is a better way to solve this than to reprint thosands of barcodes. He installs Opnsense.
In this example (that cost Daniel quite a bit of torn-out hair), Daniel is trying to do the following:
- Create a port-specific wildcard redirect on the gateway host
It's port-specific because we can't redirect everything on 10.0.0.1 as that's the gateway and Unbound DNS address and doing so would break the whole network! So we need two things:
- A port-specific LAN redirect
- A regex rewrite logic
Ha Proxy makes both of these easy to configure!
We will want to:
- Enable advanced mode
- Creating a listener at the (former) homebox instance:
We configure "option pass through":
And add:
http-request redirect code 301 prefix https://yourhomebox.instance.com if { path_beg /item/ }
Then:
- Apply
- Enable HA Proxy
Make sure that SSL is enabled if your URLs are written with both http and https (or just https)
Now the redirects will happen extremely quickly and at source - every device connected to the LAN will follow the redirect.