SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Practical Questions Regarding Rails

    There is a question that has been eating away at the back of my mind regarding Rails -- how does one run multiple applications on the same webserver?

    Suppose I have three applications:

    Depot
    CleverWikiName
    NewBlogIdea

    Normally, I could easily work on any of these three, simply by starting the WEBrick server that is neatly placed in the script directory after I generate the skeleton.

    I would access them thusly, after starting their respective servers (one at a time, or on different ports:

    http://.../depot
    http://.../clever_wiki_name
    http://.../new_blog_idea

    and let the default route take them to public/index.html.

    Now, the $1,000,000 question is:

    How can I set up my (WEBrick, if possible) server so that I can have all three applications running at the same time, on the same port?

    Further, how can I set up my WEBrick/Apache server so that I can have (say) a rails application in

    http://.../depot

    and a regular CGI ruby application in

    http://.../hiki



    Thanks!
    Ryan

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am sure there are others who have more robust solutions, but for the couple of examples I was playing around with at home, I set up a reverse proxy in my apache server to redirect various subdirectory to differnt instances of webbrick running behind my firewall. Something like:

    Code:
    ProxyRequests On
    ProxyVia On
    ProxyPass /app1/ http://localhost:3000/
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Is there any particular reason you don't want to set up separate subdomains/domains as VirtualHosts? That's what I do for local Apache/Rails development.

  4. #4
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the example I posted was localhost, but when I was actually playing with it, rails was running on a differernt box behind my firewall. I think the reverse proxy was the easiest way to expose it on a standard port.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  5. #5
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    Is there any particular reason you don't want to set up separate subdomains/domains as VirtualHosts?
    No, not at all -- I'm just so used to the PHP development/deployment system of "drag and drop" that it was like running into a (web)brick wall when I tried to deploy two Rails apps

    Quote Originally Posted by sweatje
    set up a reverse proxy in my apache server to redirect various subdirectory to differnt instances of webbrick running behind my firewall. Something like:
    I think that's exactly what I'm going to do. Everything I tried before involved unconventional apache or lighttpd configurations; I preferred using WEBBrick in the first place.

    Thank you both for your ideas. I guess I was just looking at the problem the wrong way
    Ryan

  6. #6
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, update.

    I tried using the apache-reverse-proxy technique, and it didn't quite work out for me. It would successfully forward to the WEBBrick server, yes, but all of the relative URLs in the application itself were screwed up (url_for() obviously doesn't itself know about the proxy/forwarding going on in Apache). I could maybe have changed this by editing some configuration in Apache or Rails, but "convention over configuration" is the whole reason I'm doing the Rails thing, so that didn't seem like the appropriate path to take.

    I found a little apache module called "scgi" (which, unlike the fastcgi module, worked) and it's associated ruby library (conveniently packaged as a .gem), installed it, ran it in my rails apps directory so that it could create some configuration information, and then added some info to my httpd.conf script, and viola! I'm running 3 apps on one server just as I wanted.

    For anyone else whom this may help, this is where I got the information.
    Ryan

  7. #7
    SitePoint Enthusiast kyko's Avatar
    Join Date
    May 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as running multiple apps on WebBrick it is very easy just use -p <portnumber). just type it in the command line for example:

    Code:
    script/server -p 3500
    and use different ports for different apps
    Stop Global &nbsp;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •