Par*_*ang 5 proxy nginx amazon-ec2 resque
我有两个 Amazon EC2 实例。让我称它们为 X 和 Y。我在它们上都安装了 nginx。Y 已在端口 上运行resque3000
。只有 X 具有公共 IP 和域 example.com。假设Y的私有IP是15.0.0.10
我想要的是所有请求都到达 X。并且只有当请求 url 与模式匹配时/resque
,它才应该由 Y at 处理localhost:3000/overview
,这是 resque Web 界面。看来这可以使用 nginx 配置中的 proxy_pass 来完成。
因此,在 nginx.conf 中,我添加了以下内容:
location /resque {
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
allow all;
proxy_pass http://15.0.0.10:3000/overview;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
但现在,当我http://example.com/resque
从网络浏览器访问时,它显示502 Bad Gateway
.
在/var/log/nginx/error.log
X 上,
2014/02/27 10:27:16 [error] 12559#0: *2588 connect() failed (111: Connection
refused) while connecting to upstream, client: 123.201.181.82, server: _,
request: "GET /resque HTTP/1.1", upstream: "http://15.0.0.10:3000/overview",
host: "example.com"
Run Code Online (Sandbox Code Playgroud)
关于可能出现什么问题以及如何解决这个问题有什么建议吗?
事实证明,如果需要通过寻址实例的 IP 来访问服务器,则该服务器应该在 0.0.0.0 上运行。
因此,为了解决我的问题,我停止了在 127.0.0.1:3000 上运行 resque 的服务器,然后重新启动它以绑定到 0.0.0.0:3000。其余一切都与上面相同并且有效。谢谢。
供参考:Curl 亚马逊 EC2 实例
归档时间: |
|
查看次数: |
4223 次 |
最近记录: |