我正在开发一个在 localhost:3000 上运行的 Rails 应用程序。我希望 example.com 指向 localhost:3000。我编辑了 /etc/hosts 文件,但它没有使用端口号,因此请求转到 apache。我希望 apache 站点按原样工作,但将 example.com 重定向到 rails 服务器。
请提出实现这一目标的最佳方法。
我正在开发一个在 localhost:3000 上运行的 Rails 应用程序。我希望 example.com 指向 localhost:3000。我编辑了 /etc/hosts 文件,但它没有使用端口号,因此请求转到 apache。我希望 apache 站点按原样工作,但将 example.com 重定向到 rails 服务器。
请提出实现这一目标的最佳方法。
您可以在浏览您的网站时仅指定 example.com:3000 吗?如果没有,我建议使用Phusion Passenger以便 Apache 可以在运行您的应用程序的同时继续响应端口 80。
使用 mod_proxy?
ProxyPass /your_rails_app http://your.server.address:3000
ProxyPassReverse /your_rails_app http://your.server.address:3000