2

I have a nodejs server make using websocket. Currently, i can view it in localhost by typing raspberrypi.local:5000. Now I want to portforward it so ppl from other network can view it too. How do i go about doing this ?

Thank you

  • There are several steps involved. You first need to make the node server accessible from other networks. You can configure node to listen on other interfaces, but unless you run node as root, you'll be limited to non-privileged ports > 1024. A common solution is to run nginx as a reverse proxy handling port 80 and redirecting that traffic to the node instance listening on localhost:5000 or some other port. You likely also need to configure your firewall to redirect inbound traffic to the RPi. The details for doing this will depend on your ISP and router. You need to tell us more about those. – bobstro Nov 4 '15 at 13:26
4

I'm port forwarding on my Raspberry Pi by adding these lines right before the exit line in /etc/rc.local:

# Forward port 80 to 5000 (where our web server is) so the 
# web server can run at normal permissions
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5000

This allows me to request on port 80, but have the web server running at port 5000 where it doesn't need elevated privileges to run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.