【问题标题】:EC2 Bad Gateway with torquebox and nginx带有扭矩箱和 nginx 的 EC2 错误网关
【发布时间】:2014-12-22 06:48:50
【问题描述】:

我使用扭矩箱和 nginx 设置了一个 EC2 实例(Centos 6.5)。 Torquebox 启动时没有任何错误,但我无法在端口 8080 访问它。即使我添加了 VPC 规则以打开该端口。

如果我直接访问 myip:8080 会导致网关超时,如果我使用此 nginx 配置访问 myip,则会出现错误网关:

server {
  listen 80 default deferred;
  # server_name ;
    location / {
      access_log off;
      proxy_pass http://127.0.0.1:8080;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

我尝试将 proxy_pass 设置为服务器 ip,但这也无济于事。

nginx 日志包含以下错误:

connect() failed (113: No route to host) while connecting to upstream, client: "myip", server: , request: "GET / HTTP/1.1", upstream "http://"myserverip":8080/", host: "myserverip"

我尝试只运行 rails 并访问了 myip:3000 并且测试 rails 应用程序运行良好。

有什么办法解决这个问题吗?

【问题讨论】:

    标签: ruby-on-rails nginx amazon-ec2 centos torquebox


    【解决方案1】:

    你是如何启动 TorqueBox 的?它默认绑定到 localhost,因此您要么需要将其绑定到外部接口,要么让 nginx 与 localhost:8080 对话。

    【讨论】:

    • 嗨托比!我在上面发布的 nginx 设置可以在除 EC2 之外的其他任何地方使用。试过 localhost:8080, serverip:8080 和 127.0.0.1:8080
    猜你喜欢
    • 1970-01-01
    • 2020-06-29
    • 1970-01-01
    • 2021-08-14
    • 2019-12-04
    • 1970-01-01
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多