英文:
Go Revel framework with a non-localhost, live site
问题
我正在尝试使用Go和Revel框架在我的个人网站personal-website.com上运行一个简单的应用程序。
在本地开发和测试localhost:8888时一切正常。然而,在将应用程序安装到我的Web服务器并从根目录运行# run revel personalwebsiteapp
之后,我遇到了以下错误:
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
我完全不知所措。我需要像Nginx这样的代理服务器来配合Revel吗?
这是我conf/app.conf文件中可能相关的部分:
http.addr="personal-website.com"
http.port=80 #无论我将其设置为80还是8888,都会得到相同的错误信息
英文:
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
答案1
得分: 7
我可以回答自己的问题。最终我将我的Revel应用程序路由到了Nginx,因为我无法让@Intermernet的建议使用sudo revel run
起作用。
以下是nginx.conf和Revel app.conf文件中的关键细节,以使其工作。
nginx.conf
server {
listen 80;
# listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html; # 不相关,但如果root未设置为某个值,会出错
index index.html index.htm; # 不相关
# 使站点可从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
完成后,只需启动Nginx,运行您的Revel应用程序,然后,呈现!http://my-personal-website.com现在已经上线。
英文:
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.
答案2
得分: 1
你可能需要以root身份运行(使用sudo
)来监听80端口,因为它是特权端口。
sudo run revel personalwebsiteapp
对于8888端口,你可能需要修改SELinux规则。
类似这样:
semanage port -a -t http_port_t -p tcp 8888
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论