Open malves61 opened 11 months ago
Does it work for all free ports over 1024, and not work for all free ports under 1024? This may be expected linux behavior for privileged ports and a non-root user.
Practically, you could run scanservjs in docker and use that to map port 80 to port 8080, as docker would run as root. For my setup, I use an nginx reverse proxy container to change ports and provide HTTPS to my scanservjs container, which does not have its port 8080 exposed outside a docker network to the nginx container.
I had the same problem.
I solved by running this command and restarting scanservjs service:
sudo setcap cap_net_bind_service=+ep /usr/bin/node
sudo systemctl restart scanservjs.service
This allows nodejs to use ports under 1024. More info is here: https://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-on-linux or https://stackoverflow.com/questions/60372618/nodejs-listen-eacces-permission-denied-0-0-0-080
Yes, the cleanest (and better option, in my opinion, in terms of general security concerns) is to setup a little & light reverse proxy like Caddy on your server. The configuration is very simple :
:80 {
reverse_proxy 127.0.0.1:8080
}
Or if you are comfortable with the notion of local DNS and you need to host several services on the same host but all on the port 80 :
scanserverjs.raspberry.lan:80 {
reverse_proxy 127.0.0.1:8080
}
scanserverjsdev.raspberry.lan:80 {
reverse_proxy 127.0.0.1:8081
}
app3.raspberry.lan:80 {
reverse_proxy 127.0.0.1:8082
}
After following the copy step to overriding the Server Port to 80 in /etc/scanservjs/config.local.js, scanservjs fails to start
To Reproduce Steps to reproduce the behavior:
root@scanner:~# systemctl status scanservjs.service x scanservjs.service - scanservjs Loaded: loaded (/lib/systemd/system/scanservjs.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Sun 2023-12-17 22:14:30 UTC; 2s ago Duration: 958ms Process: 678 ExecStart=/usr/lib/scanservjs/server/server.js (code=exited, status=1/FAILURE) Main PID: 678 (code=exited, status=1/FAILURE) CPU: 951ms
Dec 17 22:14:30 scanner systemd[1]: scanservjs.service: Main process exited, code=exited, status=1/FAILURE Dec 17 22:14:30 scanner systemd[1]: scanservjs.service: Failed with result 'exit-code'. Dec 17 22:14:30 scanner systemd[1]: scanservjs.service: Scheduled restart job, restart counter is at 5. Dec 17 22:14:30 scanner systemd[1]: Stopped scanservjs.service - scanservjs. Dec 17 22:14:30 scanner systemd[1]: scanservjs.service: Start request repeated too quickly. Dec 17 22:14:30 scanner systemd[1]: scanservjs.service: Failed with result 'exit-code'. Dec 17 22:14:30 scanner systemd[1]: Failed to start scanservjs.service - scanservjs.
root@scanner:~# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 443/master tcp 0 0 127.0.0.54:53 0.0.0.0:* LISTEN 104/systemd-resolve tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 104/systemd-resolve tcp6 0 0 :::22 :::* LISTEN 1/init tcp6 0 0 ::1:25 :::* LISTEN 443/master
NOTE: scanservjs starts normally if config.port is set to 8080 (on /etc/scanservjs/config.local.js) but no network devices are found (scanimage -L is OK)
root@scanner:~# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 443/master tcp 0 0 127.0.0.54:53 0.0.0.0:* LISTEN 104/systemd-resolve tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 104/systemd-resolve tcp6 0 0 :::22 :::* LISTEN 1/init tcp6 0 0 ::1:25 :::* LISTEN 443/master tcp6 0 0 :::8080 :::* LISTEN 694/node
Expected behavior scanservjs.service successful start and accessible on port 80. network devices present on web ui.
Server (please complete the following information):
Logs
This may be useful