Apache / rails / proxy issue

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

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 [email protected] 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

the issue is i will have multiple jruby / rails apps deployed under 1
glassfish app server.
Adam

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 [email protected]:

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

One app server can have multiple listeners and virtual servers.

On Sun, Oct 12, 2008 at 2:41 PM, AD [email protected] 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

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

different port for each listener.

On Sun, Oct 12, 2008 at 4:36 PM, AD [email protected] wrote:

On Sun, Oct 12, 2008 at 2:41 PM, AD [email protected] 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

Yea tomcat is ok. Just trying to figure out all the issues around
paths,
routing and ProxyPass to a J2EE instance.

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 W. wrote:

On Sun, Oct 12, 2008 at 3:56 PM, Todd W. [email protected] 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

Just so i am COMPLETELY clear :slight_smile:
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

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:







The snippet should be placed towards the bottom of the server.xml file
just above

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

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:[email protected]>> 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

On Mon, Oct 13, 2008 at 9:55 PM, AD [email protected] wrote:

Just so i am COMPLETELY clear :slight_smile:
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

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 .

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

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 [email protected] 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