linux - Go, sudo, and apache port 80 -
i using gorilla/mux package in golang, there problems. first have no permissions use port 80 on application becuase cannot run application sudo $gopath not set when using sudo.
here error program:
$ go run app.go 2014/06/28 00:34:12 listening... 2014/06/28 00:34:12 listenandserve: listen tcp :80: bind: permission denied exit status 1 i unsure if work when fix sudo problem, because apache using port 80 , not sure if both app , apache can "play nice" together.
any advice on how solve great. thank you.
quoting elithar's comment,
you have 2 options: either turn off apache (because 1 service can bind port), or (better!) use apache's proxypass proxy incoming requests specific hostname go server running on port (e.g.) 8000. second method popular, robust, , can use apache handle request logging , ssl you.
reverse proxying
using apache on port 80 in way called reverse proxy. receives incoming connections on port 80 (and/or port 443 https) , passes them on, unencrypted, via internal localhost connections only, go program running on whatever port choose. 8000 , 8080 used. traffic between apache , server is http traffic.
because go program not run root, unable alter critical functions on server. therefore gives degree of security, should program ever contain security flaws, because attacker gain limited access.
fastcgi
you can improve overall performance of reverse proxying not using http connection apache go server. done via fastcgi protocol, developed shell, perl , php scripts, working go too. use this, have modify go server listen using fcgi api. apache fastcgi required. traffic apache server uses more compact format (not http) , puts less load on each end.
the choice of socket type open: instead of usual tcp sockets, possible use unix sockets, reduce processing load further. haven't done in go myself, api supports the necessary bits (see related question).
nginx
whilst above describes using apache, there other server products can provide reverse proxy too. notable nginx (nginx reverse proxy example), give small useful performance , scalability advantages. if have option on servers, worth effort learn , deploy.
Comments
Post a Comment