【问题标题】:Redirect example.com to rails server running on localhost:3000 leaving apache sites intact?将 example.com 重定向到在 localhost:3000 上运行的 Rails 服务器,而 Apache 站点完好无损?
【发布时间】:2013-03-28 06:04:14
【问题描述】:

我正在开发一个在 localhost:3000 上运行的 Rails 应用程序。我希望 example.com 指向 localhost:3000。我编辑了 /etc/hosts 文件,但它不需要端口号,所以请求转到 apache。我希望 apache 站点按原样工作,但将 example.com 重定向到 rails 服务器。

请提出实现这一目标的最佳方法。

【问题讨论】:

    标签: ruby-on-rails linux apache hosts


    【解决方案1】:

    您可以在浏览您的网站时仅指定 example.com:3000 吗?如果没有,我建议使用Phusion Passenger 以便 Apache 可以在运行您的应用程序的同时继续响应端口 80。

    【讨论】:

    • 感谢您的建议。使用 Phusion Passenger 和 /etc/hosts 文件条目,它完全按照我想要的方式工作。使用默认指令的 Phusion 乘客不起作用。我必须在 apache 配置中添加“RailsEnv 开发”和“RackEnv 开发”才能使其工作。再次感谢您的帮助:-)
    【解决方案2】:

    使用 mod_proxy?

    ProxyPass /your_rails_app http://your.server.address:3000
    ProxyPassReverse /your_rails_app http://your.server.address:3000
    

    http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

    【讨论】:

      猜你喜欢
      • 2018-07-05
      • 1970-01-01
      • 2012-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      相关资源
      最近更新 更多