Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run n2o on 80 port?

I've tried changing port both in wf_core.erl and sys.config, but now it can't even initialize webserver.

Checked if something is using 80 port - it is free.

like image 248
akalenuk Avatar asked Oct 09 '13 06:10

akalenuk


3 Answers

You should install authbind in case you need running 80 port. Create file

/etc/authbind/byport/80 

and set rwx access to user you need run under. Then perform

authbind --deep ./start.sh

P.S. you need to specify port only in sys.config. In web_sup you should use

wf:config(port)

Like in https://github.com/synrc/n2o_sample/blob/master/src/web_sup.erl#L17

You shouldn't touch wf_core, it's default port is 8000 and it is use port from config.

like image 66
Namdak Tönpa Avatar answered Oct 20 '22 11:10

Namdak Tönpa


The basic reason is that in most unixes only root can bind to ports bellow 1024.

Depending on which OS you are running there are several ways to deal with this,

We run on port 8000 and map it to 80 at the load balancer or firewall.

If you don't want to do that look at this page: http://yaws.hyber.org/privbind.yaws which is for yaws but everything there will still apply to any erlang system.

like image 37
Zachary K Avatar answered Oct 20 '22 10:10

Zachary K


You can make it work with port-forwarding from port 80 to 8000 via iptables:

sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

sudo iptables -A INPUT -i eth0 -p tcp --dport 8000 -j ACCEPT

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000
like image 1
Jon Riel Avatar answered Oct 20 '22 10:10

Jon Riel