non-root user cannot listen to ports < 1024

Hi

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

Take a look at this: http://stackoverflow.com/questions/4138 … -1024-on-l">http://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-1024-on-l

To put it simply, you've got your work cut out for you.

Yup, ports below 1024 are considered privileged and cannot, by design, be bound to by non-root users (without root being involved, at least). It's a feature, not a bug.

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! :-)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct