rails with apache virtual hosts, mongrel

OK, dump all the virtual host stuff you're not using and under the default host put something like:

    ProxyPass /app/ http://localhost:3000/     ProxyPassReverse /app/ http://localhost:3000/        ProxyPass /app1/ http://localhost:3001/     ProxyPassReverse /app1/ http://localhost:3001/

Done.

Start page works but all of my links do not work.

Right, you'll need to set a prefix on all your routes -- I've done that once, but don't recall the incantation at the moment. Google should help.

Or, much easier, just use virtual hosts, like most folks do :slight_smile:

Ya, virtual hosts is what I am trying to do. here is the one that does not work: Any ideas?

<VirtualHost *:80> ServerName turindata DocumentRoot “F:/BACKUP/Backup/Subversion Server/httpd/deploy_apps/Turindata/public” RewriteEngine On <Directory “F:/BACKUP/Backup/Subversion Server/httpd/deploy_apps/Turindata/public” > Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all

ProxyPass / [http://localhost:3001/](http://localhost:3001/)
ProxyPassReverse / [http://localhost:3001/](http://localhost:3001/)

It "doesn't work" because you haven't, as far as I can tell, tried it.

http://turindata/ is NOT THE SAME AS http://192.168.1.1/turindata

If you don't request the virtual server you've defined, what makes you think that it will magically respond to some entirely different and unrelated request URL?

Well the virtual host above works:

<VirtualHost *:80> ServerName employees DocumentRoot “F:/BACKUP/Backup/Web_apps_svn_working/employeedb/public”

ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/

I go to http://IP/employees

and I get the index page which is what it should do.

The other one says:

Routing Error

No route matches "/turindata" with {:method=>:get}

Well the virtual host above works:

No. It. Doesn't. It ONLY APPEARS TO. Do you understand the concept of "default"?

I go to http://IP/employees

As long as you insist on trying to configure "virtual hosts" and NOT USING THE VIRTUAL HOST NAME, you are wasting your time.

Last try:

http://turindata/ is NOT THE SAME AS http://192.168.1.1/turindata

NOT. THE. SAME.

If you can't understand that, I give up.

Do you mean this statement?

NameVirtualHost *:80

I have that there.

The apache docs say that statement routes all traffic on port 80 to the virtual hosts.

If thee is something I am missing please let me know.

I have this:

NameVirtualHost *:80 ProxyRequests Off

<VirtualHost *:80> ServerName employees DocumentRoot “F:/BACKUP/Backup/Web_apps_svn_working/employeedb/public”

ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/

<VirtualHost *:80> ServerName turindata DocumentRoot “F:/BACKUP/Backup/Subversion Server/httpd/deploy_apps/Turindata/public” RewriteEngine On

ProxyPass / [http://localhost:3001/](http://localhost:3001/)
ProxyPassReverse / [http://localhost:3001/](http://localhost:3001/)

I go to this on each one:

http://192.168.1.1/employees → works http://192.168.1.1/turindata → does not work

Hi Chris,

In case you haven't already solved this problem of running multiple rails apps under the same domain via apache, ... try mod'ing your app- specific proxypass/reverse directives like:

...   ProxyPass /employees http://localhost:3000/employees   ProxyPassReverse /employees http://localhost:3000/employees ...   ProxyPass /turindata http://localhost:3001/turindata   ProxyPassReverse /turindata http://localhost:3001/turindata ...

Reload or restart apache, and you should then be able to hit those two apps as intended:

http://192.168.1.1/employees http://192.168.1.1/turindata

The only other issue you might have, depending on what those two apps do and how they're implemented, is dealing with in-app static file ref's not being found/returned via apache.

For example say the employees app had the following img ref in one of the view templates: ... <img src="/images/some-img.png" .... If you were hitting that app via localhost, your browser would fetch that img from http://localhost:3000/images/some-img.png. Under your apache setup, that file would be fetched from http://192.168.1.1/images/some-img.png. So, you'll likely need to setup your apps / apache / sys in a way that apache can find/return those static public files ref'd by each app proxy'd under that one domain (since you're wanting to serve those apps under the same domain).

There are a number of ways to deal with this, both via apache directives and rails app/config tweaks, but one fairly easy agnostic (?) kludge is to just use symbolic links:

(following is unix/linux example, but should be translatable to windows)

### create sym link to app's pub dir under that pub dir: $ cd /path-to-employees-app/public $ ln -s . ./employeespub

### create sym link to app's pub dir under main virt host domain documentroot: $ cd /path-to-domain-documentroot/htdocs $ ln -s /path-to-employees-app/public ./employeespub

### then make sure your app's static file refs point to that new sym- link: ... <img src="/employeespub/images/some-img.png" ...

### done.

After that, all of your app-specific static file refs should work under both localhost (ie http://localhost:3000/employeespub/images/some-img.png) and apache (ie http://192.168.1.1/employeespub/images/some-img.png).

Jeff