Im working on a project on my local machine Mac OSX 10.7.5 using :
- Grails 2.2.2
- Grails resources plugin 1.1.6
- Nginx 1.4
//EDIT
There is a pretty much similar question asked here but unfortunately with no answer..
//END EDIT
I have 3 directories containing some images that are located outside the web-app dir.
(as theses directories my contains a lot of images we don't want them to be into the '<project>.war' )
/Users/lorenzo/grails/projects/avatars/
/Users/lorenzo/grails/projects/posters/
/Users/lorenzo/grails/projects/waveforms/
All other images/js/css are stored under the web-app directory in different sub-directories.
web-app/images/home/
web-app/images/icons/
web-app/images/skins/
...
web-app/audioplayer/images/
web-app/audiomenu/icons/
...
web-app/js/angular/
web-app/js/angular/controllers/
...
web-app/audioplayer/js/
web-app/audioplayer/css/
web-app/audiomenu/css/
...
I have set up the nginx.conf as follow:
server {
    server_name localhost;
    listen 8080;
    access_log /usr/local/logs/access.log;
    root /Users/lorenzo/grails/projects/soundshare/grails-app;
    index /home;
    location @tomcat {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://localhost:8081;
    }
    location / {
        try_files $uri $uri/ @tomcat;
    }
    location /avatars {  
        root /Users/lorenzo/grails/projects;
    }   
    location /waveforms {
        root /Users/lorenzo/grails/projects;
    }   
    location /posters {
        root /Users/lorenzo/grails/projects;
    }   
    # what should I do here ????
    location ~* ^.+\.(js|css)$ {
        root /;
    }
}
The Grails resource plugin put the static file into a "temporary" directory called static so when the browser make a request to the server some js/css are located at
http://localhost/static/bundle-bundle_project_head.css
http://localhost/static/bundle-bundle_application_js_defer.js
Some others that are coming from grails plugin set in BuildConfig.groovy
eg: compile ":jquery-ui:1.8.24"
are locate
http://localhost/static/plugins/jquery-1.8.3/js/jquery/jquery-1.8.3.min.js
With the actual nginx config I get an nginx error
/static/bundle-bundle_application_js_defer.js" failed (2: No such file or directory)
Of course if I call it directly with port 8081 it is working. Tomcat is serving it.
http://localhost:8081/static/bundle-bundle_application_js_defer.js
But If I call it with 8080
I get the error. /static/bundle-bundle_application_js_defer.js" failed (2: No such file or directory)
Any help would be very appreciated.
Thank you
 
    