将 Rails 3.1 应用程序部署到 Apache 中的子目录而不使用 Passenger
好吧,我一整天都在为此奋斗,所以我想是时候向广大 Rails 用户提出我的问题,看看是否有人可以提供帮助。 :)
我只能使用 Windows 机器作为服务器,并且我运行 XAMPP,从 htdocs 提供静态站点。我还在端口 5000 和 5001 上运行几个瘦服务器实例,以提供两个 Rails 应用程序。我正在尝试通过 Apache 设置反向代理,以便用户可以访问 http://mydomain.com/app1 或 http://mydomain.com/app2。这是我的 proxy.conf 文件:
<Proxy *>
Order deny,allow
Allow from All
</Proxy>
ProxyVia On
ProxyPass /app1 http://localhost:5000/app1
ProxyPassReverse /app1 http://localhost:5000/app1
ProxyPass /app2 http://localhost:5001/app2
ProxyPassReverse /app2 http://localhost:5001/app2
ProxyPreserveHost On
就原始内容而言,这些应用程序似乎运行良好;但是,尽管在 app1 的环境文件中将 ENV['RAILS_RELATIVE_URL_ROOT'] 设置为“/app1”,在 app2 的环境文件中将 ENV['RAILS_RELATIVE_URL_ROOT'] 设置为“/app1”,但 javascript、样式表和图像标签不会在前面添加“/app1”或“ /app2' 到其选项卡的 HREF 和 SRC 属性,导致没有样式、脚本或图像。我已经在互联网上搜索并尝试了我能找到的所有方法,但似乎没有任何效果。我有一种感觉,我错过了一些非常基本的东西,我只是希望有人能提供帮助。 :)
Alright, I've been fighting with this all day, so I figure it's time to throw my question out into the masses of Rails users out there and see if anyone can help. :)
I'm restricted to using a Windows box as a server and I have XAMPP running, serving up a static site from htdocs. I also am running a couple of instances of Thin server off of ports 5000 and 5001 to serve up two Rails apps. I'm trying to set up a reverse proxy through Apache so that users can go to http://mydomain.com/app1 or http://mydomain.com/app2. Here's my proxy.conf file:
<Proxy *>
Order deny,allow
Allow from All
</Proxy>
ProxyVia On
ProxyPass /app1 http://localhost:5000/app1
ProxyPassReverse /app1 http://localhost:5000/app1
ProxyPass /app2 http://localhost:5001/app2
ProxyPassReverse /app2 http://localhost:5001/app2
ProxyPreserveHost On
The apps seem to work fine as far as raw content is concerned; however, despite setting ENV['RAILS_RELATIVE_URL_ROOT'] to '/app1' in the environment file for app1 and to 'app2' in the environment file for app2, the javascript, stylesheet, and image tags do not prepend '/app1' or '/app2' to the HREF and SRC attributes of their tabs, resulting in no styling, scripting, or images. I've scoured the internets and tried everything I could find, but nothing seems to works. I have a feeling I'm missing something really basic and I just hope someone can help. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个...
Try this...