How to: run custom web server on port 80

I just got myself a VPS with fresh FreeBSD 9 installed. I wrote a simple hello world custom web server. It ran ok listening on port 8080 to serve pages to internet visitors, i.e. http://domain:8080 served up the page.

But when I switched it to listen to port 80, I got:
Code:
     starting .. port # :80
And then the process exited without any error message. And http://domain failed cause the web server is not up.

I assume if I get the web server to work on port 80, then http://domain will serve up pages.

Q1: If the assumption is correct, then what do I need to set to let it listen on port 80?

Q2: If the assumption is incorrect, then how do I serve http://domain without visitor having to specify port?

The fresh install had /etc/services showing http on port 80 line.

Thanks.
 
Oh ..

Thanks! Running the process with root access obviously got my http://domain to serve pages as you mentioned @SirDice.

I have looked up man pages related to services and I could not find (or understand) if there is a configuration option / file whereby I can set non-root to access port 80. Is this possible (short of recompiling, which I am so not qualified)?
 
Forgot to mention that I also looked up jail in the handbook. It looks overly complicated for what I need.

I suppose PF is also an option to redirect inbound port 80 traffic to port higher than 1024, but I do not know if this is the way to go either. I am looking for minimal learning curve just to get started.

Thanks if anybody has any tip.
 
slamet said:
I have looked up man pages related to services and I could not find (or understand) if there is a configuration option / file whereby I can set non-root to access port 80. Is this possible (short of recompiling, which I am so not qualified)?
Stop looking for it. It doesn't exist. ALL unix and unix-like operating systems have this 'limitation'.

Apache (and all other web services) open a listening port as root and then drop their privileges as a security precaution.
 
Back
Top