Quantcast

Can't load static resource via apache proxy

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can't load static resource via apache proxy

reperion
Hi there.

i'm new in grails and i'm not familiar in english. :)

So.
when i connect with apache, can't read resource
http://site/static/images/grails_logo.png

when i connect with tomcat, can read resource
http://site:8080/static/images/grails_logo.png

i just make scaffoled page and use resource tag
ex:) <img src="${resource(dir: 'images', file: 'grails_logo.png')}" alt="Grails"/>

if i change that img tag to
 Grails

It all works.(apache and tomcat)

I'm using grails 2.0 and also use resources plugin 1.1.5
apache config is
        ProxyPass / ajp://localhost:8009/
        ProxyPassReverse / ajp://localhost:8009

How can i read static resource via apache?
need help T^T.  ty
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can't load static resource via apache proxy

carina
Hi,

I think I'm having the same issue. Did you find a solution?

A summary of my situation and what I've tried so far:

I'm using Grails 2.0 and the resources plugin. My application is available at http://mysite.com:8080/appname but I want to make it available http://mysite.com by using mod_proxy.

Everything works nicely as long as one of the following two point applies:
- I deploy the application in the root context ( =>http://mysite.com/static/style.css is found)
- I deploy the application in the appname context but don't use mod_proxy  (=> http://mysite.com:8080/appname/static/style.css is found)

The problem starts when I want to use mod_proxy and use my "appname" context at the same time. In this case, http://mysite.com/appname/static/style.css is included but not found. It would be available at http://mysite.com/static/style.css instead.

This is my mod_proxy configuration:
  ProxyPass / http://mysite.com:8080/appname/
  ProxyPassReverse / http://mysite.com:8080/appname/

I've tried changing the application.context in application.properties to "/" but this didn't help and it would not be a solution anyway since I want to be running multiple application instances in the same tomcat.
I also tried to set grails.resources.uri.prefix to various values such as:
- grails.resources.uri.prefix = "/static"  => included file is: http://mysite.com:8080/appname//static/style.css, the file is now neither available at this location nor at http://mysite.com/static/style.css
- grails.resources.uri.prefix = "../static"  => included file is: http://mysite.com/static/style.css but the file is not found there; warning message in log is: "We can't create resources on the fly unless they are 'ad-hoc', we're going to 404"

I've tried to also include this proxy configuration but this did not help either:
   ProxyPass /appname/static/  http://mysite.com/static/
    ProxyPassReverse /appname/static/  http://mysite.com/static/


I even tried setting grails.resources.processing.enabled = false since this is only a test server but that did not work either since in that case no resources are included at all. It works fine when I try it locally but not on the server where I'm running from a war file in the production environment. Is this the expected behavior?

Does anyone have any suggestions? Thanks in advance!


Kind regards
Carina


P.S.: To anyone who reads this because he wants to do the same thing: you'll also need to set:  ProxyPassReverseCookiePath /appname /
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can't load static resource via apache proxy

Ian Roberts
On 10/02/2012 06:11, carina wrote:
> The problem starts when I want to use mod_proxy and use my "appname" context
> at the same time. In this case, http://mysite.com/appname/static/style.css
> is included but not found. It would be available at
> http://mysite.com/static/style.css instead.
>
> This is my mod_proxy configuration:
>   ProxyPass / http://mysite.com:8080/appname/
>   ProxyPassReverse / http://mysite.com:8080/appname/

To be honest I've always avoided situations where the front-end and
back-end context paths are different, for precisely these kinds of
reasons.  However I've never really found it necessary since Tomcat
itself supports name-based virtual hosting.  If you turn on
ProxyPreserveHost in your Apache configuration then you can configure
several <Host> blocks in the server.xml of a single Tomcat, each <Host>
having its own webapps directory and each responding to a different host
name (or names).

http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

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

    http://xircles.codehaus.org/manage_email


Loading...