How do I get Raspberry Pi to allow non-root process to bind to port 80 on reboot?

I just switched my node-red flows from a headless MacBook to a Raspberry Pi 400. I'm using node-red-contrib-amazon-echo-oztourer to send voice commands locally to Alexa. This seems to require access to port 80. I came across this nifty way to get access without node-red needing root access. It works great, but now I can't quite figure out how to get it to survive a reboot.

Any tips or even just pointing me in the right direction to figure it out myself would be greatly appreciated.

sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 3000

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000

I can't quite remember the exact recipe but you should be able to get node-red access to port 80 by configuring the systemd startup script correctly. Those scripts run at system level and so provide access that would otherwise need root. That's how web servers are able to get access to port 80 even though they always run under their own user/group.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.