Forum: JRuby apache / rails / proxy issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-12 16:16
(Received via mailing list)
hello,
 I posted this in Glassfish forum as well, but would see what you guys
think.

 I am having trouble with routes and apache mod_proxy_balancer with
Glassfish and Jruby rails application.  Can anyone share how this is
properly supposed to be setup ?

 I tried doing

 ProxyPass / http://localhost:8080/myapp/
 ProxyPassReverse / http://localhost:8080/myapp/

 But i get an error in glassfish server.log "No route matches
/myapp/session/new"

I tried messing with the

#ActionController::AbstractRequest.relative_url_root = "/myapp/"
#ActionController::CgiRequest.relative_url_root = "/myapp/"

but to no avail.  Also i dont want /myapp/ to show up in the URL path
when a
user is browsing, it seems glassfish was redirecting to
/myapp/session/new
back to apache which was causing issues as well.

Any help here appreciated.

Thanks
Adam
2f78fbe49e2dc2412879a6536f56bcca?d=identicon&s=25 Todd Willey (Guest)
on 2008-10-12 19:42
(Received via mailing list)
I've been using create-virtual-server + create-http-listener (with the
default virtual server I just created) to create a virtual server to
deploy to.  When I deploy I deploy to the virtual server with
contextroot of /.

Then I only have to proxy to a given port, and not worry about paths.

-todd[1]

On Sun, Oct 12, 2008 at 10:07 AM, AD <straightflush@gmail.com> wrote:
>  But i get an error in glassfish server.log "No route matches
>
--
CONFIDENTIALITY NOTICE:  This email is for sole use of intended
recipient(s).  Unauthorized use is prohibited.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-12 20:41
(Received via mailing list)
the issue is i will have multiple jruby / rails apps deployed under 1
glassfish app server.
Adam
9e4c54d501d4bcb232a8469b04d7696e?d=identicon&s=25 Gabe Wong (Guest)
on 2008-10-12 21:45
(Received via mailing list)
Hi AD,
You can deploy multiple instances of the same app, however if
you require them to be deployed as context-roots (/), then you
need to follow Todd's suggestion.

There is no extra configuration necessary if deployed as app1,app2, etc.



Quoting AD <straightflush@gmail.com>:

>>
>> > properly supposed to be setup ?
>> when a
>> --
>
Regards,
Gabe Wong

--
cloudAPPy.com
Drag-and-Drop Cloud Hosting


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
2f78fbe49e2dc2412879a6536f56bcca?d=identicon&s=25 Todd Willey (Guest)
on 2008-10-12 21:57
(Received via mailing list)
One app server can have multiple listeners and virtual servers.

On Sun, Oct 12, 2008 at 2:41 PM, AD <straightflush@gmail.com> wrote:
>>
>> > properly supposed to be setup ?
>> > when a
>> --
>
--
CONFIDENTIALITY NOTICE:  This email is for sole use of intended
recipient(s).  Unauthorized use is prohibited.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-12 22:36
(Received via mailing list)
All on the same IP / Port ? Or do these require different ports  ?
Just trying to make sure I understand the root cause of why this can not
be
done with normal mod_proxy_balancer setup..

Thanks for the tips guys.

Adam
2f78fbe49e2dc2412879a6536f56bcca?d=identicon&s=25 Todd Willey (Guest)
on 2008-10-13 17:45
(Received via mailing list)
different port for each listener.

On Sun, Oct 12, 2008 at 4:36 PM, AD <straightflush@gmail.com> wrote:
>> On Sun, Oct 12, 2008 at 2:41 PM, AD <straightflush@gmail.com> wrote:
>> >>
>> >> > Glassfish and Jruby rails application.  Can anyone share how this is
>> >> > but to no avail.  Also i dont want /myapp/ to show up in the URL path
>> >>
>> >
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>



--
CONFIDENTIALITY NOTICE:  This email is for sole use of intended
recipient(s).  Unauthorized use is prohibited.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
9e4c54d501d4bcb232a8469b04d7696e?d=identicon&s=25 Gabe Wong (Guest)
on 2008-10-13 18:03
(Received via mailing list)
Hi Adam,
Another option you have, is that if you are not completely tied to
Glassfish, you can use Tomcat, which has a more comprehensive
Virtual Hosting support for what you are looking for.

Todd Willey wrote:
>> On Sun, Oct 12, 2008 at 3:56 PM, Todd Willey <todd@rubidine.com> wrote:
>>>>
>>>>>
>>>>>>
>>>>>> Any help here appreciated.
>>>>> To unsubscribe from this list, please visit:
>>>
>
>


--
Regards

Gabe Wong
cloudAPPy
the Drag-and-drop Hosting CLOUD
http://www.cloudappy.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-13 18:46
(Received via mailing list)
Yea tomcat is ok.  Just trying to figure out all the issues around
paths,
routing and ProxyPass to a J2EE instance.
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-14 03:56
(Received via mailing list)
Just so i am COMPLETELY clear :-)
It is not possible through apache_mod_proxy to deploy 1 application like

  ProxyPass / ajp://localhost:8009/myapp/

without the /myapp/ anywhere in the website.  The only way to do this is
to
deploy the war to a context root of "/", which would require a new
virtualhost for each war Rails app ?

Thanks again
Adam
9e4c54d501d4bcb232a8469b04d7696e?d=identicon&s=25 Gabe Wong (Guest)
on 2008-10-14 04:36
(Received via mailing list)
Hi AD:
 I will illustrate a Tomcat example below.

client1.mydomain.com --> appinstance1 -->
/home/tomcatuser/apache-tomcat-6x/webapps/appinstance1
client2.mydomain.com --> appinstance2 -->
/home/tomcatuser/apache-tomcat-6x/webapps/appinstance2


In each Tomcat node, place the following in the server.xml file:

<Host name="client1.mydomain.com"
appBase="/home/tomcatuser/apache-tomcat-6x/webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path=""
docBase="/home/tomcatuser/apache-tomcat-6x/webapps/appinstance1">
 </Context>
</Host>

<Host name="client2.mydomain.com"
appBase="/home/tomcatuser/apache-tomcat-6x/webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path=""
docBase="/home/tomcatuser/apache-tomcat-6x/webapps/appinstance2">
 </Context>
</Host>

The snippet should be placed towards the bottom of the server.xml file
just above </Engine>

In the Apache mod_proxy config place the following or similar:
ProxyPass / balancer://clouda_1_0/ stickysession=JSESSIONID
<Proxy balancer://clouda_1_0>
BalancerMember ajp://srv2.cloud:8116 route=qcbxxrda-s7000-srv2_1
loadfactor=50
BalancerMember ajp://srv1.cloud:8116 route=qcf7xjo5-pointer-srv1_1
loadfactor=50
</Proxy>

You may also want to check the Tomcat list.
Hope this helps you get started.




AD wrote:
> Thanks again
>     Virtual Hosting support for what you are looking for.
>             All on the same IP / Port ? Or do these require different
>
>                     glassfish app server.
>                         deploy to.  When I deploy I deploy to the
>                         <mailto:straightflush@gmail.com>> wrote:
>                              Can anyone share how this is
>                             #ActionController::AbstractRequest.relative_url_root
>                             well.
>                         recipient(s).  Unauthorized use is prohibited.
>
>
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe from this list, please visit:
>
>       http://xircles.codehaus.org/manage_email
>
>
>


--
Regards

Gabe Wong
cloudAPPy
the Drag-and-drop Hosting CLOUD
http://www.cloudappy.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
2f78fbe49e2dc2412879a6536f56bcca?d=identicon&s=25 Todd Willey (Guest)
on 2008-10-14 17:18
(Received via mailing list)
On Mon, Oct 13, 2008 at 9:55 PM, AD <straightflush@gmail.com> wrote:
> Just so i am COMPLETELY clear :-)
> It is not possible through apache_mod_proxy to deploy 1 application like
>   ProxyPass / ajp://localhost:8009/myapp/

Well, it's probably possible, but problematic, as per your first post.

> without the /myapp/ anywhere in the website.  The only way to do this is to
> deploy the war to a context root of "/", which would require a new
> virtualhost for each war Rails app ?

That is the method I use, and would be a solution to the route
problem.  Out of curiosity, what happens if you navigate directly to
http://localhost:8009/myapp/ in your browser, without proxying through
apache?  That should let you know if you need to tune mod_proxy, or
the appserver/rails app.

>>
>>>> done with normal mod_proxy_balancer setup..
>>>>>>
>>>>>>> default virtual server I just created) to create a virtual server to
>>>>>>>> hello,
>>>>>>>>  But i get an error in glassfish server.log "No route matches
>>>>>>>> Any help here appreciated.
>>>>>>> To unsubscribe from this list, please visit:
>>>>> recipient(s).  Unauthorized use is prohibited.
>>>
>> the Drag-and-drop Hosting CLOUD
>
--
CONFIDENTIALITY NOTICE:  This email is for sole use of intended
recipient(s).  Unauthorized use is prohibited.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-14 20:06
(Received via mailing list)
things work fine at http://localhost:8009/myapp/.  All the paths in the
app
are prefixed with /myapp/ though, my guess is this is something that
Warbler
and Rack do .
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2008-10-14 21:06
(Received via mailing list)
Correct, and therein lies your problem: All links are getting rendered
with /myapp in them, so that when you proxy those requests, they're
going back to the app as /myapp/myapp/... and Rails is seeing the
extra /myapp prefix.

Seems like the only way to fix this is to turn off JRuby-Rack's
automatic setting of relative_url_root. To do this, you'll need the
following monkeypatch (offending code commented):

    class JRuby::Rack::RailsSetup
      def call(env)
        env['rails.session_options'] =
@servlet_helper.session_options_for_request(env)
        env['HTTPS'] = 'on' if env['rack.url_scheme'] == 'https'
        # relative_url_root = env['java.servlet_request'].getContextPath
        # if relative_url_root && !relative_url_root.empty?
        #   env['RAILS_RELATIVE_URL_ROOT'] = relative_url_root
        #   ActionController::Base.relative_url_root =
relative_url_root if
ActionController::Base.respond_to?(:relative_url_root=)
        # end
        @app.call(env)
      end
    end

Put that in environment.rb or in config/initializers so that it gets
loaded once at Rails startup.

/Nick

On Tue, Oct 14, 2008 at 12:28 PM, AD <straightflush@gmail.com> wrote:
>>
>> apache?  That should let you know if you need to tune mod_proxy, or
>> >> Glassfish, you can use Tomcat, which has a more comprehensive
>> >>>> Just trying to make sure I understand the root cause of why this can
>> >>>>> One app server can have multiple listeners and virtual servers.
>> >>>>>> wrote:
>> >>>>>>> paths.
>> >>>>>>>> think.
>> >>>>>>>> /myapp/session/new"
>> >>>>>>>> Thanks
>> >>>>>>> To unsubscribe from this list, please visit:
>> >>>>> recipient(s).  Unauthorized use is prohibited.
>> >>>>
>> >> cloudAPPy
>> >
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 AD (Guest)
on 2008-10-15 03:17
(Received via mailing list)
well the initial request to rails seems fine for the root action, rails
does
not see a double /myapp/, but as you said the links are prefixed with
the
context root, and all 302 redirects have the relative_url_root sent back
to
apache which is breaking this.
THanks for the tip here, will give it a try.

Adam
This topic is locked and can not be replied to.