Rails with apache virtual hosts, mongrel

On Sat, Jan 31, 2009 at 8:46 AM, Me [email protected] wrote:

huh, well I am doing it according to the apache docs.

I go to http://192.168.1.1/turindata
I should be able to go to http://192.168.1.1/employeedb

One more time – the above has nothing to do with “virtual hosts”.
Nothing. At. All. Let’s try again.

Check one, and only one:

[ ] I want to access my apps as separate virtual hosts, as in:
http://employeedb/
http://turindata/

[ ] I want to access my apps on one host, in this case ‘192.168.1.1’,
using different paths:
http://192.168.1.1/turindata
http://192.168.1.1/employeedb

Those are your choices. Either is easily implemented.

Just make up your mind.


Hassan S. ------------------------ [email protected]

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

On Jan 31, 11:10 am, Hassan S. [email protected]

On Sat, Jan 31, 2009 at 11:51 AM, Me [email protected] wrote:

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:


Hassan S. ------------------------ [email protected]

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/
ProxyPassReverse / http://localhost:3001/

On Sat, Jan 31, 2009 at 3:48 PM, Hassan S. <

On Sat, Jan 31, 2009 at 2:02 PM, Chris H. [email protected]
wrote:

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

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?


Hassan S. ------------------------ [email protected]

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}

On Sat, Jan 31, 2009 at 4:16 PM, Hassan S. <

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/
ProxyPassReverse / 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

On Sat, Jan 31, 2009 at 4:38 PM, Hassan S. <

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

On Sat, Jan 31, 2009 at 2:21 PM, Chris H. [email protected]
wrote:

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.


Hassan S. ------------------------ [email protected]