【问题标题】:Rails App on Port 80 on Amazon EC2 - Use Nginx or IpTablesAmazon EC2 上端口 80 上的 Rails 应用程序 - 使用 Nginx 或 IpTables
【发布时间】:2013-08-02 04:57:31
【问题描述】:

我在 EC2 上设置了一个简单的 Rails 应用程序,并使用 Unicorn 运行它。我现在想对其进行设置,使其在端口 80 上运行。在 unicorn_rails 命令中使用 -p 标志不起作用;我收到一条错误消息,提示权限被拒绝:

[ec2-user@ip-10-164-110-7 current]$ unicorn_rails -p 80
F, [2013-08-02T04:41:41.441613 #3297] FATAL -- : error adding listener addr=0.0.0.0:80
/home/ec2-user/uc_social_server/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in `initialize': Permission denied - bind(2) (Errno::EACCES)
    from /home/ec2-user/uc_social_server/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in `new'
    from /home/ec2-user/uc_social_server/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in `bind_listen'

在线搜索解决方案,我一直在寻找有关设置 Nginx + Unicorn 的帖子。然后有一些提到使用 IpTables 将端口 8080 的流量重定向到端口 80。

我不确定采用哪种方法。

我需要 Nginx 吗?

有没有办法让 ec2-user 在 80 端口上运行独角兽进程?

IpTables 解决方案是一个好方法吗?不知怎的,我不这么认为。

【问题讨论】:

    标签: amazon-ec2 unicorn


    【解决方案1】:

    在这里,他们显然解决了unicorn -p 的问题:

    Unable to start unicorn on port 80 using capistrano

    其他两个解决方案也都可以正常工作。

    使用 IPtables,您可以将来自端口 80 的传入流量重定向到侦听 8080 的独角兽套接字并返回。这发生在 TCP 层。

    nginx 方法是一种透明的代理设置。所有的魔法都发生在 HTTP 层上,它为您提供了能够操纵请求和响应、设置缓存等的优势。nginx 是一个可爱的工具,它可能远远超过了独角兽的可能性(并且不会真正减慢你的速度)

    【讨论】:

    • 我试过unicorn -p,同样的错误。我在应用程序上的合作者认为我们现在不需要 Nginx。我会去尝试 IpTables 解决方案,将端口 80 的流量重定向到端口 8080。
    • 我最终使用了 IpTables。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2013-06-28
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 2016-10-16
    • 2019-05-27
    • 1970-01-01
    相关资源
    最近更新 更多