non-root user cannot listen to ports < 1024
I'm in the process of setting up Ubuntu 11.10 as a web server for a personal website plus testing and playing around. I've installed the Cherokee web server after reading positive reviews of it and am looking for a way to bind port 80 to localhost so that I can run the server as a non root user.
I have successfully run the software on port 8080. I have run
netstat -lp
to ensure nothing is running on port 80 already.
Here is the error that appears when trying to start cherokee via cherokee-admin when started as root
Could not bind() port=80 (UID=0, GID=0)
Most probably there is another web server listening to the same port. You will have to shut it down before launching Cherokee. It could also be a permissions issue as well. Remember that non-root user cannot listen to ports < 1024.
Perhaps this is just me being a bit thick but some advice as to how to proceed would be gratefully appreciated.
regards,
Richard
2 Replies
To put it simply, you've got your work cut out for you.
The usual approach is either to start the web server as root (practically all modern web servers will immediately drop to a non-root uid after binding) or run it on a non-privileged port and have a proxy server redirect stuff up to it. iptables REDIRECT is worth some attention, as well.
On the bright side, everything above 1024 is free and clear for non-root users!