Not sure if this list is still active but I haven''t found another yet, here''s my setup and question. * I''m running a camping app using a mongrel server listening at 127.0.0.1:X. * I have a virtual host setup in Apache that is rewriting my_vhost.net/my_app/ to 127.0.0.1:X. * In one of my controllers I''m trying to redirect to another controller like this: redirect Index * Instead of being directed to my_vhost.net/my_app/ though the user is directed to 127.0.0.1:X. What''s the best/cleanest way to get around this and have the controller redirect to my_vhost.net/my_app/? -- Dave
Camping uses the Host-header to figure out where the app is located, and
Apache *should* carry forward the header to the Mongrel. How have you set
this up?
If you''re using Camping 1.9 or running this through Rack, you could
always
create a middleware which changes the Host-header:
class Thing
def initialize(app, options = {})
@app = app
end
def call(env)
@app.call(env.merge({ ''HTTP_HOST'' =>
''my_vhost.net'' }))
end
end
app = Thing.new(app)
-------
I also believe Apache is able to modify HTTP-headers.
//Magnus Holm
On Tue, May 19, 2009 at 15:31, David Susco <dsusco at gmail.com> wrote:
> Not sure if this list is still active but I haven''t found another
yet,
> here''s my setup and question.
>
> * I''m running a camping app using a mongrel server listening at
127.0.0.1:
> X.
> * I have a virtual host setup in Apache that is rewriting
> my_vhost.net/my_app/ to 127.0.0.1:X.
> * In one of my controllers I''m trying to redirect to another
> controller like this: redirect Index
> * Instead of being directed to my_vhost.net/my_app/ though the user is
> directed to 127.0.0.1:X.
>
> What''s the best/cleanest way to get around this and have the
> controller redirect to my_vhost.net/my_app/?
>
> --
> Dave
> _______________________________________________
> Camping-list mailing list
> Camping-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/camping-list/attachments/20090519/f9dfd47a/attachment.html>
Within an apache vhost I''m rewriting like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L]
</IfModule>
I haven''t gotten to deployment yet, so I''m not sure if this is
what
I''m actually going to be doing so suggestions are welcome.
Ideally though (since I''ll have multiple camping apps) I''d
like to
have apache forward to many mongrel servers that will be serving up
the apps.
Dave
On Tue, May 19, 2009 at 10:21 AM, Magnus Holm <judofyr at gmail.com>
wrote:> Camping uses the Host-header to figure out where the app is located, and
> Apache *should* carry forward the header to the Mongrel. How have you set
> this up?
> If you''re using Camping 1.9 or running this through Rack, you
could always
> create a middleware which changes the Host-header:
> class Thing
> ??def initialize(app, options = {})
> ?? ?@app = app
> ??end
>
> ??def call(env)
> ?? ?@app.call(env.merge({ ''HTTP_HOST'' =>
''my_vhost.net'' }))
> ??end
> end
> app = Thing.new(app)
> -------
> I also believe Apache is able to modify HTTP-headers.
>
> //Magnus Holm
>
>
> On Tue, May 19, 2009 at 15:31, David Susco <dsusco at gmail.com>
wrote:
>>
>> Not sure if this list is still active but I haven''t found
another yet,
>> here''s my setup and question.
>>
>> * I''m running a camping app using a mongrel server listening
at
>> 127.0.0.1:X.
>> * I have a virtual host setup in Apache that is rewriting
>> my_vhost.net/my_app/ to 127.0.0.1:X.
>> * In one of my controllers I''m trying to redirect to another
>> controller like this: redirect Index
>> * Instead of being directed to my_vhost.net/my_app/ though the user is
>> directed to 127.0.0.1:X.
>>
>> What''s the best/cleanest way to get around this and have the
>> controller redirect to my_vhost.net/my_app/?
>>
>> --
>> Dave
>> _______________________________________________
>> Camping-list mailing list
>> Camping-list at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>
>
> _______________________________________________
> Camping-list mailing list
> Camping-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
--
Dave
I ended up overwriting the redirect method with this: def redirect *a r(302, '''', ''Location'' => ''my_vhost.net/my_app/'' + R(*a).to_s) end Thoughts? Dave On Tue, May 19, 2009 at 11:05 AM, David Susco <dsusco at gmail.com> wrote:> Within an apache vhost I''m rewriting like this: > > ? ?<IfModule mod_rewrite.c> > ? ? ?RewriteEngine On > ? ? ?RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f > ? ? ?RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L] > ? ?</IfModule> > > I haven''t gotten to deployment yet, so I''m not sure if this is what > I''m actually going to be doing so suggestions are welcome. > > Ideally though (since I''ll have multiple camping apps) I''d like to > have apache forward to many mongrel servers that will be serving up > the apps. > > Dave > > On Tue, May 19, 2009 at 10:21 AM, Magnus Holm <judofyr at gmail.com> wrote: >> Camping uses the Host-header to figure out where the app is located, and >> Apache *should* carry forward the header to the Mongrel. How have you set >> this up? >> If you''re using Camping 1.9 or running this through Rack, you could always >> create a middleware which changes the Host-header: >> class Thing >> ??def initialize(app, options = {}) >> ?? ?@app = app >> ??end >> >> ??def call(env) >> ?? ?@app.call(env.merge({ ''HTTP_HOST'' => ''my_vhost.net'' })) >> ??end >> end >> app = Thing.new(app) >> ------- >> I also believe Apache is able to modify HTTP-headers. >> >> //Magnus Holm >> >> >> On Tue, May 19, 2009 at 15:31, David Susco <dsusco at gmail.com> wrote: >>> >>> Not sure if this list is still active but I haven''t found another yet, >>> here''s my setup and question. >>> >>> * I''m running a camping app using a mongrel server listening at >>> 127.0.0.1:X. >>> * I have a virtual host setup in Apache that is rewriting >>> my_vhost.net/my_app/ to 127.0.0.1:X. >>> * In one of my controllers I''m trying to redirect to another >>> controller like this: redirect Index >>> * Instead of being directed to my_vhost.net/my_app/ though the user is >>> directed to 127.0.0.1:X. >>> >>> What''s the best/cleanest way to get around this and have the >>> controller redirect to my_vhost.net/my_app/? >>> >>> -- >>> Dave >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Dave >-- Dave
It works, but it''s a little weird Camping can''t detect it itself. Anyway, the most important thing is that it works :-) //Magnus Holm On Wed, May 20, 2009 at 19:53, David Susco <dsusco at gmail.com> wrote:> I ended up overwriting the redirect method with this: > > def redirect *a > r(302, '''', ''Location'' => ''my_vhost.net/my_app/'' + R(*a).to_s) > end > > Thoughts? > > Dave > > On Tue, May 19, 2009 at 11:05 AM, David Susco <dsusco at gmail.com> wrote: > > Within an apache vhost I''m rewriting like this: > > > > <IfModule mod_rewrite.c> > > RewriteEngine On > > RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f > > RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L] > > </IfModule> > > > > I haven''t gotten to deployment yet, so I''m not sure if this is what > > I''m actually going to be doing so suggestions are welcome. > > > > Ideally though (since I''ll have multiple camping apps) I''d like to > > have apache forward to many mongrel servers that will be serving up > > the apps. > > > > Dave > > > > On Tue, May 19, 2009 at 10:21 AM, Magnus Holm <judofyr at gmail.com> wrote: > >> Camping uses the Host-header to figure out where the app is located, and > >> Apache *should* carry forward the header to the Mongrel. How have you > set > >> this up? > >> If you''re using Camping 1.9 or running this through Rack, you could > always > >> create a middleware which changes the Host-header: > >> class Thing > >> def initialize(app, options = {}) > >> @app = app > >> end > >> > >> def call(env) > >> @app.call(env.merge({ ''HTTP_HOST'' => ''my_vhost.net'' })) > >> end > >> end > >> app = Thing.new(app) > >> ------- > >> I also believe Apache is able to modify HTTP-headers. > >> > >> //Magnus Holm > >> > >> > >> On Tue, May 19, 2009 at 15:31, David Susco <dsusco at gmail.com> wrote: > >>> > >>> Not sure if this list is still active but I haven''t found another yet, > >>> here''s my setup and question. > >>> > >>> * I''m running a camping app using a mongrel server listening at > >>> 127.0.0.1:X. > >>> * I have a virtual host setup in Apache that is rewriting > >>> my_vhost.net/my_app/ to 127.0.0.1:X. > >>> * In one of my controllers I''m trying to redirect to another > >>> controller like this: redirect Index > >>> * Instead of being directed to my_vhost.net/my_app/ though the user is > >>> directed to 127.0.0.1:X. > >>> > >>> What''s the best/cleanest way to get around this and have the > >>> controller redirect to my_vhost.net/my_app/? > >>> > >>> -- > >>> Dave > >>> _______________________________________________ > >>> Camping-list mailing list > >>> Camping-list at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/camping-list > >> > >> > >> _______________________________________________ > >> Camping-list mailing list > >> Camping-list at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/camping-list > >> > > > > > > > > -- > > Dave > > > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20090520/5792545c/attachment.html>