Asa Hopkins
2006-Jul-28 17:04 UTC
[Mongrel] URL root/serving more than one app per subdomain
Hey folks, I have the following situation: I have a secure server, and I''d like to run multiple Rails apps without dealing with setting up multiple secure servers, with their fixed IPs, etc. So, I want to do https:// secure.domain.com/app1/ and https://secure.domain.com/app2/ etc. In lighttpd this is possible using a combination of relative_url_root in each app (in environment.rb), some URL handling in lighttpd.conf, and mod_alias, which maps "/app1" to the public directory for app1, etc, so that stylesheets, images, etc, get served right. I''m trying out switching to an Apache/Pound/Mongrel setup (on PlanetArgon''s servers). Pound can handle directing to different ports for different URLs, so I can sent /app1/ to port 3000, and / app2/ to port 3010, for example. This works with separate Mongrels running on those different ports, except that Mongrel can''t find the stylesheets and other "assets". That is, the app runs fine, but looks awful and has no javascript. Yesterday as I was setting this up, I managed to get it to work by hacking Mongrel itself. i added a "-u" (--urlroot) flag to mongrel_rails, added a @urlroot variable to the RailsHandler, and added the following lines to change the request path: In rails.rb/RailsHandler#process path_info = path_info[@urlroot.length, path_info.length- @urlroot.length] unless @urlroot.nil? or path_info[0, at urlroot.length]! =@urlroot and in handlers.rb / DirHandler#process path_info = request.params[Const::PATH_INFO] path_info = path_info[urlroot.length,path_info.length- urlroot.length] unless urlroot.nil? or path_info[0,urlroot.length]! =urlroot req_path = can_serve path_info I imagine there are other places where such a parameter might need to be added to get serving things other than rails apps to work right. I also didn''t try to add it to the Windows service binaries. So, I guess my question is twofold: 1) I''m new to making changes/adding features to open source code. How would I go about lobbying for this feature (if not the code that I wrote) to be included in a release, so that when PlanetArgon updates their gems I can use this feature there? 2) Lacking that, how do I create a separate copy of mongrel that uses my changes and ignores the installed gems? Thanks! Asa ----------------- Work is love made visible ----------------- Asa S. Hopkins MC 266-33, Pasadena, CA 91125 asa at caltech.edu http://www.its.caltech.edu/~asa/ ----------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20060728/8fbb600f/attachment.html