Rewriting URL's before they hit the app

2 views
Skip to first unread message

Jacob Atzen

unread,
Apr 28, 2009, 10:06:44 AM4/28/09
to Phusion Passenger Discussions
Hi group,

I've been trying to get passenger to rewrite URL's for my Rails app.
What I would like is for:

http://foo.bar.com/page to be seen from the Rails app like
http://my.app.com/foo.bar.com/page so that I can do page caching for
different domains within one app.

So far I have been unable to get passenger to do this by itself. I've
tried with the following rewrite code in Apache:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my\.app\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/system
RewriteRule ^/(.*)$ /%{HTTP_HOST}/$1 [QSA,PT,L]

From the rewrite log it seems that the request is being rewritten
correctly. Also Apache is able to serve page cached pages correctly.
Only problem is that Rails keeps seeing the original url /page instead
of /foo.bar.com/page.

I've written up a patch that makes Passenger/Rails do what I want,
it's at: http://code.google.com/p/phusion-passenger/issues/detail?id=230

But I'm suspecting I might be doing something wrong as the Phusion
guys already have done a lot of work on getting Passenger to play nice
with rewrite.

So the question is: Is what I'm doing wrong? Bad? Or just plain
stupid? Have anyone else been able to get Passenger to understand a
rewritten URL?

Any clues, config samples and thoughts are most welcome.

--
Thanks,
- Jacob Atzen

Hongli Lai

unread,
Apr 28, 2009, 1:01:59 PM4/28/09
to phusion-...@googlegroups.com
I've posted a followup on the bug tracker.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Reply all
Reply to author
Forward
0 new messages