We have a Centos server with a number of virtual hosts, and my rails app runs under one of those virtual hosts using mongrel_rails. The app lives in /home/mydomain/railsapp where /home/mydomain/railsapp/public is the rails root. It runs under mongrel on port 8008, so to get to it users invoke the url http://www.mydomain.com:8008/ - all is fine to this point. Now I have some users whose firewalls forbid these semantics, so I went and configured apache (v1.3) to have mod_proxy in an attempt to get the :8008 out of the URLs the user submits. With a simple rule like: ProxyPass / http://mydomain.com:8008/ ProxyPassReverse / http://mydomain.com:8008/ It works beautifully when the user invokes http://www.mydomain.com. I believe all my paths within the app are relative to the rails root. Now here is the PROBLEM. I cannot use ''/'' for the proxy since mydomain.com needs to work for the website that already predates the rails app, and in fact wants to offer it to it''s users. So I changed the mod_proxy rules in apache to: ProxyPass /myapp/ http://mydomain.com:8008/ ProxyPassReverse /myapp/ http://mydomain.com:8008/ I did this in hopes users could specify http://www.mydomain.com/myapp/ Well this works but the problem is that all the links I created using the link_to method do not invoke http://www.mydomain.com/tourney/controller/etc, the merely are relative hrefs that look like href="/mycontroller/mymethod/etc" and as a result do not go to the proper pages. How do I fix this? Why is it different when I specify a subdir versus just specifying ''/'' in my proxy? I have tried using: ActionController::AbstractRequest.relative_url_root = "/myapp" and it just does not help. I am extremely confused and tired. I can''t help but feel I''m getting close. It''s taken the last 2 days to get mod_proxy working. Any help is appreciated. -- Posted via http://www.ruby-forum.com/.
On Thu, 2006-07-27 at 01:23 +0200, Mike Kogan wrote:> ActionController::AbstractRequest.relative_url_root = "/myapp" and it > just does not help. I am extremely confused and tired. I can''t help but > feel I''m getting close. It''s taken the last 2 days to get mod_proxy > working. Any help is appreciated.Try the current mongrel 0.3.13.4 pre-release: sudo gem install mongrel --source=http://mongrel.rubyforge.org/releases/ And use the --prefix setting. That''ll do it. Let me know how it works otherwise. I''ve got bugs in the queue to be fixed next week. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.railsmachine.com/ -- Need Mongrel support?
Zed- Thanks for the reply -- I''ll be happy to try it, but if I have problems how do I get back to the current version? Just do another install? I''ll give it a shot this afternoon. -- Posted via http://www.ruby-forum.com/.
On Thu, 2006-07-27 at 11:04 +0200, Mike Kogan wrote:> Zed- > > Thanks for the reply -- I''ll be happy to try it, but if I have problems > how do I get back to the current version? Just do another install? > > I''ll give it a shot this afternoon. >Yes, you should be able to do: gem uninstall mongrel And then tell it to uninstall all versions just to clear everything out. Finally, just do: gem install mongrel -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.railsmachine.com/ -- Need Mongrel support?
OK Zed I have the latest installed and everything runs fine as before in the basic setup where I just run off http://www.mydomain.com:8008/ However I am confused as to how to use the URI. If I set the prefix to anything when mongrel starts it says it is listening and available on 0.0.0.0:refix. Should I be using my mod_proxy rules for dereferencing http://www.mydomain.com/myapp into http://www.mydomain.com:8008/ and still running mongrel on port 8008 as before? If I set the prefix I cannot get to my app at all -- I probably am not using it properly. I need some direction. Thanks in advance, Mike p.s. - pls feel free to communiate directly, I have been writing sys s/w for 20+ years. -- Posted via http://www.ruby-forum.com/.
Zed I mad some progress. I disabled all the mod_proxy business. I took my app which was in /home/mydomain/test with railsroot=/home/mydomain/test/public, and copied the whole tree over to /home/mydomain/public_html -- so now there is /home/mydomain/public_html/test with the usual rails subdirs under it. If I start up mongrel_rails start -prefix /test/public I can reference the app by the URL http://www.mydomain.com/test/public. All my link-to''s are fine. I did find that anywhere in a view where I hand-coded html for an image where I said <img src="/images/test.gif"> did not work. However if I recoded it to use <%= image_tag etc %> instead it found the images properly. I have one remaining problem - I use file column for images, and everywhere I use image_tag(url_for_file_column(.....)) I am getting the prefix twice. That is the images are assigned to be at http://www.mydomain.com/test/public/test/public/classname/images/imagenum instead of http://www.mydomain.com/test/public/classname/images/imagenum I also have to confess things look noticeably slower with the prefix. -- Posted via http://www.ruby-forum.com/.