3

I'm trying to use Go and the Revel framework to run a simple app on my live, personal-website.com.

Everything is ok when I develop locally and test localhost:8888. However after installing on my web server and running my app from root, # run revel personalwebsiteapp I get the following error:

ERROR 2013/10/01 04:01:35 harness.go:167: Failed to start reverse proxy: listen tcp xx.xxx.xx.xx:80: cannot assign requested address

At a total loss here. Do I need to run a proxy server like Nginx or something on top of Revel?

Here's what could be a relevant part of my conf/app.conf file:

http.addr="personal-website.com"
http.port=80 #whether I set this to 80 or 8888 doesn't matter, I get the same error
tim peterson
  • 23,653
  • 59
  • 177
  • 299

2 Answers2

7

I can answer my own question. I ended up routing my Revel app to Nginx b/c I could never get @Intermernet's suggestion of using sudo revel run to work.

Below are the key details from the nginx.conf and Revel app.conf files to make this work.

nginx.conf

server {
        listen 80;
#       listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html; # not relevant, but gives error if root isn't set to something
        index index.html index.htm; # not relevant

        # Make site accessible from http://localhost/
#       server_name localhost;

        server_name my-personal-website.com;

                location / {
                        proxy_pass      http://127.0.0.1:9000;
                }
        }

}

Go Revel personalwebsiteapp app.conf

http.addr="127.0.0.1"
http.port=9000

After this, just start up Nginx, run your revel app and viola!, http://my-personal-website.com is now live.

tim peterson
  • 23,653
  • 59
  • 177
  • 299
1

You probably need to run as root (use sudo) to listen on port 80 as it's a Privileged Port.

sudo run revel personalwebsiteapp

For port 8888, you may need to modify the SELinux rules.

Something like:

semanage port -a -t http_port_t -p tcp 8888
Intermernet
  • 18,604
  • 4
  • 49
  • 61
  • thanks for the suggestion. I was in fact running as root, sorry for the lack of clarification. I updated my question. But just for completness, `sudo run revel personalwebsiteapp` doesn't work due to `-bash: revel: command not found`. I'd like to use port 80 rather than 8888 because `personal-website.com` rather than `personal-website.com:8888` is the common means through which outside users will find the page. – tim peterson Oct 01 '13 at 05:40
  • In that case, I'd highly recommend NginX or HAProxy. – Intermernet Oct 01 '13 at 05:47
  • NGINX doesn't appear to be necessary: http://stackoverflow.com/questions/17776584/webserver-for-go-golang-webservices-using-nginx-or-not – tim peterson Oct 01 '13 at 05:49
  • @timpeterson It's not, but as *I* said in that answer, it's a much better solution. "revel: command not found" is likely an issue with your GOPATH and GOBIN environmental variables. – elithrar Oct 01 '13 at 06:15
  • Thanks for the tip on GOBIN. ok, trying to figure out how to hook up Revel to Nginx. I'm no NGINX expert. Any demo nginx.conf's lying around? This gist isn't quite working for me... https://gist.github.com/tim-peterson/6774608 – tim peterson Oct 01 '13 at 06:34
  • @timpeterson Have a look at http://wiki.nginx.org/FullExample . You really only need the top section and the "reverse proxy" section. – Intermernet Oct 01 '13 at 07:02
  • I think I understand most of the example, but i'm confused on what the `root` and `index` specifically refer to in the case of a Revel app. Can you [check my updated Gist](https://gist.github.com/tim-peterson/6774608)? (which doesn't work yet, very top part omitted for clarity). – tim peterson Oct 01 '13 at 08:00
  • @timpeterson try adding a space between `http` and `{` on the first line, and removing the `~` from the location line, and maybe even commenting out the `index` line. Make it as simple as possible for debugging. NginX can be very picky when it comes to exact syntax. – Intermernet Oct 01 '13 at 08:16
  • dangit no go still: `ERROR 2013/10/01 08:18:52 harness.go:167: Failed to start reverse proxy: listen tcp xx.xxx.xx.xx:8888: cannot assign requested address` – tim peterson Oct 01 '13 at 08:19
  • I think the issue is with the `root` but can't figure out how to prove that – tim peterson Oct 01 '13 at 08:21
  • @timpeterson good call. Pretty sure you don't need `root`. You're just passing the traffic to the go web server, no need to know where the files are located. Try commenting it out and see how it goes. – Intermernet Oct 01 '13 at 08:46
  • yeah commenting out `root` still didnt work. I'm going to pose this out the Revel Github page and see if they might chime in... – tim peterson Oct 01 '13 at 12:55
  • please see Github for further discussion on this question https://github.com/robfig/revel/issues/331 – tim peterson Oct 01 '13 at 16:14