Hi folks, Newbie issues...I''m prototying an Apache/Mongrel configuration setup as follows: * Two Mongrel servers each serving a Rails application. * Apache front-end. * Linux system (CentOS) * The plan is to create two virtual hosts. /ETC/HOSTS LOOKS LIKE THIS: # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost egovm04 10.4.1.84 rss 10.4.1.84 railstest HTTPD.CONF LOOKS LIKE THIS: [snip] NameVirtualHost 10.4.1.84 <VirtualHost rss> ServerName rss ServerAlias rss RewriteEngine on RewriteRule ^/rss(.*) http://10.4.1.84:5432$1 <http://10.4.1.84:5432/>[P] ProxyPass / http://10.4.1.84:5432/ ProxyPassReverse / http://10.4.1.84:5432/ </VirtualHost> <VirtualHost railstest> ServerName railstest ServerAlias railstest RewriteEngine on RewriteRule ^/railstest(.*) http://10.4.1.84:8021$1<http://10.4.1.84:8021/>[P] ProxyPass / http://10.4.1.84:8021/ ProxyPassReverse / http://10.4.1.84:8021/ </VirtualHost> ISSUES 1. App 1 (rss) URL rewrite problem. Typing ''http://10.4.1.84/rss'' <http://10.4.1.84/rss%27> in the browser correctly accesses app #1 (rss), HOWEVER... This: ''http://10.4.1.84/rss/about'' <http://10.4.1.84/rss/about%27> finds the right page, but the URL is rewritten to this: ''http://10.4.1.84/about'' <http://10.4.1.84/about%27> 2. App # 2 not found. Typing this: ''http://10.4.1.84/railstest'' <http://10.4.1.84/railstest%27>yields this: Routing Error Recognition failed for "/railstest" This is a Rails message reported by app # 1( rss). So the (Apache) server is not redirecting to the second Virtual Host (railstest). Sorry for the question, I''m quite sure this is a setup problem on my part. Thanks, Stan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070207/ff145793/attachment-0001.html
You have the server names as "rss" and "railstest", don''t you have to access them via those hosts? http://rss/about Otherwise Apache defaults to the first VirtualHost definition. On 2/7/07, Stan Baptista <stan.baptista at gmail.com> wrote:> > Hi folks, > > Newbie issues...I''m prototying an Apache/Mongrel configuration setup > as follows: > > * Two Mongrel servers each serving a Rails application. > * Apache front-end. > * Linux system (CentOS) > * The plan is to create two virtual hosts. > > /ETC/HOSTS LOOKS LIKE THIS: > > # Do not remove the following line, or various programs > # that require network functionality will fail. > 127.0.0.1 localhost.localdomain localhost egovm04 > 10.4.1.84 rss > 10.4.1.84 railstest > > HTTPD.CONF LOOKS LIKE THIS: > > [snip] > > NameVirtualHost 10.4.1.84 > > <VirtualHost rss> > ServerName rss > ServerAlias rss > > RewriteEngine on > RewriteRule ^/rss(.*) http://10.4.1.84:5432$1 <http://10.4.1.84:5432/>[P] > > ProxyPass / http://10.4.1.84:5432/ > ProxyPassReverse / http://10.4.1.84:5432/ > > </VirtualHost> > > <VirtualHost railstest> > > ServerName railstest > ServerAlias railstest > > RewriteEngine on > RewriteRule ^/railstest(.*) http://10.4.1.84:8021$1<http://10.4.1.84:8021/>[P] > > ProxyPass / http://10.4.1.84:8021/ > ProxyPassReverse / http://10.4.1.84:8021/ > > </VirtualHost> > > ISSUES > > 1. App 1 (rss) URL rewrite problem. > > Typing ''http://10.4.1.84/rss'' <http://10.4.1.84/rss%27> in the browser > correctly accesses app #1 > (rss), HOWEVER... > > This: '' http://10.4.1.84/rss/about'' <http://10.4.1.84/rss/about%27> finds > the right page, but the URL > is rewritten to this: ''http://10.4.1.84/about'' <http://10.4.1.84/about%27> > > 2. App # 2 not found. > > Typing this: ''http://10.4.1.84/railstest'' <http://10.4.1.84/railstest%27>yields this: > > Routing Error > Recognition failed for "/railstest" > > This is a Rails message reported by app # 1( rss). So the (Apache) > server is not redirecting to the second Virtual Host (railstest). > > Sorry for the question, I''m quite sure this is a setup problem on my > part. > > Thanks, > Stan > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070207/a138d469/attachment.html
Michael, Thanks for your help.> You have the server names as "rss" and "railstest", don''t you have toaccess them via those hosts? If I put these entries in my local hosts file: 10.4.1.84 rss 10.4.1.84 railstest they are then accessible from my browser using these addresses: http://rss http://railstest Adding them to my local computer''s hosts file is OK for my own use but there are a few other folks I''d like to show these to scattered throughout the site where I work and I''d like to find a way to do this other than modifying the hosts file on each system. One of the webmasters here thought it was sufficient to add the lines above to the _remote_ system''s hosts file and adding RewriteRules to each VirtualHost directive. The goal is to be able to do this from anywhere: http://10.4.1.84/rss http://10.4.1.84/railstest (But no;-) As you suggested, the remote system is taking the first VirtuaHost directive and is actually trying to find "railstest" on the first Mongrel site (rss) and, of course, not finding it. -Stan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070207/c9777b17/attachment.html
Hi! On Wed, Feb 07, 2007 at 11:36:58AM -1000, Stan Baptista wrote:> Michael, > > Thanks for your help. > > >You have the server names as "rss" and "railstest", don''t you have to > access them via those hosts? > > If I put these entries in my local hosts file: > > 10.4.1.84 rss > 10.4.1.84 railstest > > they are then accessible from my browser using these addresses: > > http://rss > http://railstest > > Adding them to my local computer''s hosts file is OK for my own use but there > are a few other folks I''d like to show these to scattered throughout the > site where I work and I''d like to find a way to do this other than modifying > the hosts file on each system. > > One of the webmasters here thought it was sufficient to add the lines > above to the _remote_ system''s hosts file and adding RewriteRules to each > VirtualHost directive.that can''t work, because the client (the browser) needs to send a correct Host header for Apache to know which virtual host definition to use. Usually the value for that host header is taken from the location the user entered into the location bar. If possible you should get some admin to create dns records for these host names pointing to your IP, so that everyone can use these host names to access your apps.> > The goal is to be able to do this from anywhere: > > http://10.4.1.84/rss > http://10.4.1.84/railstestYou won''t get to work this with apache virtual hosts. instead you need to mount your apps under these paths, I didn''t ever do this but afair it has been discussed on the list several times. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
>that can''t work, because the client (the browser) needs to send acorrect Host header for Apache to know which virtual host definition to use. Usually the value for that host header is taken from the location the user entered into the location bar. If possible you should get some admin to create dns records for these host names pointing to your IP, so that everyone can use these host names to access your apps. I got this working as follows: /etc/hosts: # Do not remove the following line, or various programs> > # that require network functionality will fail.127.0.0.1 localhost.localdomain localhost egovm0410.4.1.84 rss10.4.1.84 railstest > > /usr/local/apache22/conf/httpd.conf:NameVirtualHost 10.4.1.84> > <VirtualHost 10.4.1.84> > > RewriteEngine on > RewriteRule ^/rss(.*) http://10.4.1.84:5432$1 [P] > RewriteRule ^/railstest(.*) http://10.4.1.84:8021$1 [P] > > </VirtualHost> > > <VirtualHost 10.4.1.84> > > ServerName rss > ProxyPass / http://10.4.1.84:5432/ > ProxyPassReverse /rss http://10.4.1.84:5432/ > ProxyPreserveHost on > > </VirtualHost> > > <VirtualHost 10.4.1.84> > > ServerName railstest > ProxyPass / http://10.4.1.84:8021/ > ProxyPassReverse /railstest http://10.4.1.84:8021/ > ProxyPreserveHost on > > </VirtualHost> > >Note that three VirtualHost directives are required. The first (default) is to create the rewrite rules and the next two contain the ProxyPass... directives that map to the Mongrel servers. Issues Typing this in the browser: http://egovm04.higov.net/rss/about> >Correctly accesses the about page, but the address in the browser shows this: http://egovm04.higov.net/about> > Link mappings within the browser do not work correctly (most likely not anApache problem.) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070208/7be708cd/attachment.html
On Wed, 7 Feb 2007 08:53:47 -1000 "Stan Baptista" <stan.baptista at gmail.com> wrote:> Hi folks, > > Newbie issues...I''m prototying an Apache/Mongrel configuration setup > as follows: > > * Two Mongrel servers each serving a Rails application. > * Apache front-end. > * Linux system (CentOS) > * The plan is to create two virtual hosts.Did you get this resolved Stan? -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://www.awprofessional.com/title/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
> Did you get this resolved Stan?Yes, thanks. Basically a misunderstanding on my part about how VirtualHost directives work in the Apache httpd.conf file. I meant to post the solution because I''m curious as to whether I came up with the best approach. But it will have to wait until next week when I''m back in the office and have access to the Linux system (4-day weekend:-) I also discovered that the CSS styles aren''t rendering in the Rails app being served by Mongrel. I strongly suspect it''s a ReverseProxy setup issue. I''m a little hesitant to bring this up here since I don''t think it''s a Mongrel problem. But I''ll post some of the code and if it seems too OT, let me know. -Stan> Newbie issues...I''m prototying an Apache/Mongrel configuration setup > as follows: > > * Two Mongrel servers each serving a Rails application. > * Apache front-end. > * Linux system (CentOS) > * The plan is to create two virtual hosts.-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070216/92ba3247/attachment.html
On 2/16/07, Stan Baptista <stan.baptista at gmail.com> wrote:> > > Did you get this resolved Stan? > > Yes, thanks. Basically a misunderstanding on my part about how VirtualHost > directives work in the Apache httpd.conf file. I meant to post the > solution because I''m curious as to whether I came up with the best approach. > But it will have to wait until next week when I''m back in the office and > have access to the Linux system (4-day weekend:-) > > I also discovered that the CSS styles aren''t rendering in the Rails app > being served by Mongrel. I strongly suspect it''s a ReverseProxy setup issue. > I''m a little hesitant to bring this up here since I don''t think it''s a > Mongrel problem. But I''ll post some of the code and if it seems too OT, let > me know. >I''m using Apache 2.2. Here''s a snip of httpd.conf.:> NameVirtualHost 10.4.1.84 > > <VirtualHost 10.4.1.84> > > RewriteEngine on > RewriteRule ^/rss(.*) http://10.4.1.84:5432$1 [P] > RewriteRule ^/railstest(.*) http://10.4.1.84:8021$1 [P] > > </VirtualHost> > > <VirtualHost 10.4.1.84> > > ServerName rss > ProxyPass / http://10.4.1.84:5432/ > ProxyPassReverse /rss http://10.4.1.84:5432/ > ProxyPreserveHost on > > </VirtualHost> > > <VirtualHost 10.4.1.84> > > ServerName railstest > ProxyPass / http://10.4.1.84:8021/ > ProxyPassReverse /railstest http://10.4.1.84:8021/ > ProxyPreserveHost on > > </VirtualHost> >-Stan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070220/563a10a2/attachment.html
I''m researching the reverseproxy situation on a side project, not mongrel-related, but relevant I believe. You might want to look at the following page... http://apache.webthing.com/mod_proxy_html/ This rewrites inline html urls when using reverse proxies and has an "extended" option that looks into linked stylesheets and JS files to rewrite urls there too. Dunno if this will help with your problem but it might connect a few neurons. matte - webmonkey matte at ruckuswireless.com Stan Baptista wrote:> On 2/16/07, *Stan Baptista* <stan.baptista at gmail.com > <mailto:stan.baptista at gmail.com>> wrote: > > > Did you get this resolved Stan? > > Yes, thanks. Basically a misunderstanding on my part about how > VirtualHost directives work in the Apache httpd.conf file. I meant > to post the solution because I''m curious as to whether I came up > with the best approach. But it will have to wait until next week > when I''m back in the office and have access to the Linux > system (4-day weekend:-) > > I also discovered that the CSS styles aren''t rendering in the > Rails app being served by Mongrel. I strongly suspect it''s a > ReverseProxy setup issue. I''m a little hesitant to bring this up > here since I don''t think it''s a Mongrel problem. But I''ll post > some of the code and if it seems too OT, let me know. > > > > I''m using Apache 2.2. Here''s a snip of httpd.conf.: > > > NameVirtualHost 10.4.1.84 <http://10.4.1.84> > > <VirtualHost 10.4.1.84 <http://10.4.1.84>> > > RewriteEngine on > RewriteRule ^/rss(.*) http://10.4.1.84:5432$1 [P] > RewriteRule ^/railstest(.*) http://10.4.1.84:8021$1 [P] > > </VirtualHost> > > <VirtualHost 10.4.1.84 <http://10.4.1.84>> > > ServerName rss > ProxyPass / http://10.4.1.84:5432/ > ProxyPassReverse /rss http://10.4.1.84:5432/ > ProxyPreserveHost on > > </VirtualHost> > > <VirtualHost 10.4.1.84 <http://10.4.1.84>> > > ServerName railstest > ProxyPass / http://10.4.1.84:8021/ > ProxyPassReverse /railstest http://10.4.1.84:8021/ > ProxyPreserveHost on > > </VirtualHost> > > > > -Stan >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070220/cb4b7068/attachment.html