Setup Guide: Raspberry Pi | Use Port 80 (OPTIONAL)
Normally, CNCjs uses port 8000 to communicate between the browser and the CNCjs server (hence the :8000 in the URL localhost:8000). If you browse to a URL that does not have the ":8000" part, the implied port number is 80, the standard port number for the http protocol. So if you want to access CNCjs without having to add the :8000 to the URL, you could redirect port 80 to port 8000. This would not work if you are already running a web server on the Pi, because that web server would already be using port 80.
You might think that you could add --port 80 to the cncjs command line, but that does not work because port 80 (as with all ports below 1024) is privileged, so it can only be used by processes running under the special administrative user root. CNCjs runs as a normal user process (typically user pi on a Raspberry Pi), so it will fail if you specify a port number less than 1024.
The workaround is to use the system's routing software to redirect port 80 to port 8000. When a request comes in on port 80, the routing software forwards the request to port 8000. Here's how:
# Iptables (allow access to port 8000 from port 80)
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8000
# Make Iptables Persistent
sudo apt-get install iptables-persistent -y
# How-to: Save & Reload Rules
#sudo netfilter-persistent save
#sudo netfilter-persistent reload
# How-to: Manually Save Rules
#sudo sh -c "iptables-save > /etc/iptables/rules.v4"
#sudo sh -c "ip6tables-save > /etc/iptables/rules.v6"
# Run this if issues to reconfigure iptables-persistent
# sudo dpkg-reconfigure iptables-persistent
Join CNCjs Users Group on Facebook to share your experiences with other people.
Site: https://cnc.js.org
- Introduction
- Installation
- Using Pendants
-
Raspberry Pi Setup Guide
- System Setup & Preparation
- Install Node.js & CNCjs
- Install Node.js via Package Manager (Recommended)
- Install Node.js via Node Version Manager (NVM) (Alternative)
- Install Node.js Manually (Alternative)
- Use PM2 to auto-start CNCjs (Optional)
- Use Port 80 (Optional)
- Maintain
- Additional Setup Options:
- CNCjs UI on Pi - Adventures in PiLand
- Pi with Arduino Due
- Electron App
- User Guide
- Tool Change
- Troubleshooting
-
FAQ
- Forgot your password?
- How can I enable WebGL in my browser?
- Raspberry Pi: Error opening serial port "ttyAMA0"
- Webcam Streaming with Raspberry Pi
- Restream RTSP to M-JPEG
- Connect to an Arduino using WiFi
- Install Native Addons with Node.js v4
- Install Serialport on OS X El Capitan
- Kernel panic issue on macOS Sierra for devices using the CH340G, CH34G or CH34X chipset
- Testing without Arduino board
- Development
- API
- Wiki History
- Resources
- About