Hi guys,
I am currently serving my css and js static files with nginx. But so far, all these were generated in the default root path. For example: <script type="text/javascript" src="/JQDevelopmentLibrary/jQuery.js"></script> etc... Now...I would like to be able to set a different prefix path. For example, 'siteX', and then urls become: <script type="text/javascript" src="/siteX/JQDevelopmentLibrary/jQuery.js"></script> Why I want this? Because I want to be able to catch these into nginx locations and search the files in different places. Any idea how can I do this? Thanks, Mariano http://marianopeck.wordpress.com _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Can you provide a full URL (‘http://www.example.com/siteX/Lib/jQuery.js')?
The rule is that (for security reasons) you can’t reach any files outside your domain. James On Oct 10, 2014, at 12:12 PM, Mariano Martinez Peck <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Mariano Martinez Peck
Is the "siteX" stable? or is something dynamic?
If it is stable you can define a FileHandler at '/siteX/', and then in your code generate the URL's using WAFileHandler's #urlOf:using: e.g. | fileHandler | fileHandler := WAFileHandler new. fileHandler preferenceAt: #resourceBaseUrl put: (WAUrl absolute: 'siteX') . (fileHandler libraryAt: #TBSDeploymentLibrary ifAbsent: []) default urlOf: #cssbootstrapminCss using: fileHandler. At runtime I guess you would ask the FileHandler to your dispatcher (or the default). | fileHandler | fileHandler := WADispatcher default handlerAt: 'siteX' ifAbsent:[]. (fileHandler libraryAt: #TBSDeploymentLibrary ifAbsent: []) default urlOf: #cssbootstrapminCss using: fileHandler. It's a little convoluted for my taste, however. Maybe simply setting #resourceBaseUrl to 'siteX' in your WAApplication (at root) would do the trick. ps: another option is to use an extension based pattern in nginx, using try_files for all requests of "static" content (I didn't test it). Like: location ~* \.(?:jpg|jpeg|gif|css|png|js)$ { try_files $uri; expires 30d; # etc... } See http://serverfault.com/questions/537569/nginx-serve-static-files-directly-if-not-matched-by-rewrite-rules Regards, Esteban A. Maringolo 2014-10-10 16:12 GMT-03:00 Mariano Martinez Peck <[hidden email]>: > Hi guys, > > I am currently serving my css and js static files with nginx. But so far, > all these were generated in the default root path. For example: > > <script type="text/javascript" > src="/JQDevelopmentLibrary/jQuery.js"></script> > <link rel="stylesheet" type="text/css" > href="/TBSDevelopmentLibrary/css/bootstrap.css"/> > > etc... > > Now...I would like to be able to set a different prefix path. For example, > 'siteX', and then urls become: > > <script type="text/javascript" > src="/siteX/JQDevelopmentLibrary/jQuery.js"></script> > <link rel="stylesheet" type="text/css" > href="/siteX/TBSDevelopmentLibrary/css/bootstrap.css"/> > > Why I want this? Because I want to be able to catch these into nginx > locations and search the files in different places. > > Any idea how can I do this? > > Thanks, > > -- > Mariano > http://marianopeck.wordpress.com > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Mariano Martinez Peck
This what the resource base url setting [1] does.
I’m guessing you are including Seaside’s file libraries to add these resources to your application but that nginx captures the url’s generated by Seaside? I think you have two options: - forget about file libraries served by Seaside and reference the statically served files yourself (in #updateRoot: you do `` aRoot stylesheet resourceUrl: '/stylesheets/main.css’ ‘ ‘' ) - change the location where Seaside serves the file libraries (this is configurable) Hope this helps Johan On 10 Oct 2014, at 21:12, Mariano Martinez Peck <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Thank you Esteban and James (more below). On Sat, Oct 11, 2014 at 4:12 AM, Johan Brichau <[hidden email]> wrote:
OK, good. I didn't know that one.
Well, this is what I wanted to do and I already saw that link. But I had /config disabled from my nginx config...and in any case, I wanted to do that via code. I ended up doing: WAFileHandler default preferenceAt: #resourceBaseUrl put: (WAUrl new addToPath: '/mariano/webfiles'). Is this the expected way? It seems a bit clunky... but at least the links were generated as I wanted. Esteban, the "Maybe simply setting #resourceBaseUrl to 'siteX' in your WAApplication (at root) would do the trick.". That didn't help. Reviewing the code I notived that I HAD to set the preference to WAFileHandler default, not the app... In any case....all of this was to try to fix a requirement I have but I at end I am not sure if even adding this preffix would help me. The requirement is here if someone han answer in mind ;) http://stackoverflow.com/questions/26285450/nignx-try-files-in-different-directories-for-different-locations Thanks in advance,
Mariano http://marianopeck.wordpress.com _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |