To run on port 80 you need to run as root, so it's best to drop privileges
after setting up the listening port. You do this with process.setgid and
process.setuid. See how Haraka does it here:
https://github.com/baudehlo/Haraka/blob/master/server.js#L267

Though I highly recommend running a front end proxy like nginx instead.
It's just easier and faster and gives you a bunch of easy to use features
over making node the entire front end server.

On Sat, Sep 27, 2014 at 4:03 PM, Adam Reynolds <[email protected]>
wrote:

> Is consider using iptables to forward port 80 traffic to your node
> instance.
> On 27 Sep 2014 20:48, "Craig Coleman" <[email protected]> wrote:
>
>> I'd like to try running nodejs on port 80 on a debian and gentoo server
>> I've seen a lot post how people do this but I'd like to get some
>> additional advice so I don't screw things up on our test servers.
>> I'm just getting started with node.
>> I have installed hapi
>> Thanks, cwc
>>
>> var Hapi = require('hapi');
>> var server = new Hapi.Server(80);
>>
>> server.route({
>>     method: 'GET',
>>     path: '/',
>>     handler: function (request, reply) {
>>         reply('Hello, world!');
>>     }
>> });
>>
>> server.route({
>>     method: 'GET',
>>     path: '/{name}',
>>     handler: function (request, reply) {
>>         reply('Hello, ' + encodeURIComponent(request.params.name) + '!');
>>     }
>> });
>>
>> server.start(function () {
>>     console.log('Server running at:', server.info.uri);
>> });
>>
>>
>>  --
>> Job board: http://jobs.nodejs.org/
>> New group rules:
>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>> Old group rules:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/nodejs/feeda1ed-67bd-4259-8f9e-cf42e68e7876%40googlegroups.com
>> <https://groups.google.com/d/msgid/nodejs/feeda1ed-67bd-4259-8f9e-cf42e68e7876%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/CAFszCkOf8vg9-W6MH-Jiu1AZ5Z9T_kq9J_6tLDtWNqrVkEwuqA%40mail.gmail.com
> <https://groups.google.com/d/msgid/nodejs/CAFszCkOf8vg9-W6MH-Jiu1AZ5Z9T_kq9J_6tLDtWNqrVkEwuqA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAPJ5V2aMLiMsj%3DwrM%2B17j%2BDNevpNza-fsYn0MmzJdNUi%2BMcAHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to