maybe I have a fix .
Can you please test it ?
assuming an example of routes.py like

myapp = dict(languages=['en', 'it', 'jp'], default_language='en')


this means that navigating to:
 /myapp/ --> the static files will be referenced as 
web2py_home/applications/myapp/en/static/whatever.css
 /myapp/it/ --> the static files will be referenced as 
web2py_home/applications/myapp/it/static/whatever.css

however, direct requests to /myapp/static/whatever.css should map to 
web2py_home/applications/myapp/en/static/whatever.css

additionally, if /myapp/it/static/whatever.css is requested, if not found 
web2py_home/applications/myapp/static/whatever.css should be served.

Now, I think that adding this section before the standard one will fix the 
issue

location ~* /(\w+)/(en|it|jp)/static/(.*)$ {
            alias /home/www-data/web2py/applications/$1/;
            try_files static/$2/$3 static/$3 =404;
        }

(en|it|jp) here is the regex matching the "languages" list of the routes 
app's dict .... This will set for the request /myapp/it/static/whatever.css 
  the alias to the web2py_home/applications/myapp/ and then try to serve 
static/it/whatever.css, if not found, it will fall back to a "normal" 
static/whatever.css, and if that one is not found will return a 404.

@Jonathan: please stop me if I did miss something in the routes logic
@all : seems a simple fix - maybe too simple... please help test it

On Tuesday, January 22, 2013 9:14:26 PM UTC+1, Niphlod wrote:
>
> got it. can you post the routes.py you're using ?
>
> The problem lies in the fact that routes.py is really flexible and 
> adapting that logic using only rewrite or alias statements in nginx is 
> cumbersome.
> Standing on one feet (i.e. without tests) I'd say that the regex checking 
> static files
>
>         location ~* /(\w+)/static/ {
>             root /home/www-data/web2py/applications/;
>             #remove next comment on production
>             #expires max;
>         }
>
> is catching it as the app name and not the language "trick" . so, for a 
> request going to /it/app/static/whatever.css is looking into 
> /home/www-data/web2py/applications/*it/*appname/static/whatever.css instead 
> of  ..... (remove the bold part, "*it/*").
>
> If you remove those lines web2py will take charge for static files 
> serving, so the issue will be temporarily fixed.
>
> I'll try to set up some additional rules to make nginx behave like 
> routes.py, but it will take some time.
>
> PS: please mind that the script it's a template.... it's not meant to 
> fullfill every custom installation patterns out there without further 
> tuning.
> language routing is probably the most difficult out there because for a 
> request
> /it/appname/static/whateverfile.css
> web2py looks into /web2py/appname/static/it/whateverfile.css and then if 
> not found into /web2py/appname/static/whateverfile.css (a nice fallback, 
> but hard to map with a simple nginx statement)
>
> On Tuesday, January 22, 2013 6:14:55 PM UTC+1, Paolo valleri wrote:
>>
>> Hi Massimo, for example, if I visit this 
>> traffic.integreen-life.bz.it/default/wiki/about  (default is the 
>> controller and wiki is the function) it works while 
>> traffic.integreen-life.bz.it/it/default/wiki/about the application works 
>> very well but the static links do not.
>>
>> Paolo
>>
>>
>> 2013/1/22 Massimo Di Pierro <[email protected]>
>>
>>> can you show an example?
>>>
>>>
>>> On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:
>>>
>>>> Hi all, I've just discovered that the regex used to retrieve the static 
>>>> files doesn't work if I use languages abbreviation in urls.
>>>> How can we fix this?
>>>>
>>>>
>>>>
>>>> 2012/12/28 Richard Vézina <[email protected]>
>>>>
>>>>>  Hello,
>>>>>
>>>>> I publish a new script that allow deployment of Redmine beside web2py.
>>>>>
>>>>> Here : https://groups.google.com/**forum/?fromgroups=#!searchin/**
>>>>> web2py/redmine/web2py/**ZqL7Si8Khbo/Es-wK1yXdgQJ<https://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ>
>>>>>
>>>>> Notice : After some read, I choose Unicorn over Phussion Passenger.
>>>>>
>>>>> Richard
>>>>>
>>>>>
>>>>> On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> please email me the patch of latest file when ready for inclusion.
>>>>>>
>>>>>>
>>>>>> On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:
>>>>>>>
>>>>>>> perfect, Ccing Massimo on this final one.
>>>>>>>
>>>>>>> Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>> I was trying with the script that comes with the stable web2py. 
>>>>>>>> with the one on dropbox I problem has gone. 
>>>>>>>>
>>>>>>>> Paolo 
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/12/19 Niphlod <[email protected]>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> @Simone, an other improvement to the script could be to combine 
>>>>>>>>>> into a single server the 80, and 443 to avoid duplicating 
>>>>>>>>>> configuration, as 
>>>>>>>>>> stated here :
>>>>>>>>>> http://nginx.org/en/docs/http/******configuring_https_servers.**
>>>>>>>>>> html****#single_http_https_server<http://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server>
>>>>>>>>>> I don't had test this.
>>>>>>>>>>
>>>>>>>>>> Also, here the code for permanent redirection 
>>>>>>>>>> server {
>>>>>>>>>>   server_name $hostname;
>>>>>>>>>>   listen              80;
>>>>>>>>>>   return 301 http*s*://$hostname$request_uri; # NOTE: I am not 
>>>>>>>>>> sure for $hostname here, because I didn't set hostname for my VM 
>>>>>>>>>> until now, 
>>>>>>>>>> as in the example (URL below) we can use domainName.com instead if 
>>>>>>>>>> properly 
>>>>>>>>>> configure in nginx
>>>>>>>>>> ...
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> People may want separate configs for http and https. The script 
>>>>>>>>> objective is to have a working copy of web2py. If we start to follow 
>>>>>>>>> such 
>>>>>>>>> requests, we'd end up installing postgresql and redis too :P 
>>>>>>>>>
>>>>>>>>> @Paolo: try the script found at the dropbox link. If the same 
>>>>>>>>> error happens I think we need the log of pip and a hand by Roberto on 
>>>>>>>>> the 
>>>>>>>>> specific error...
>>>>>>>>>  
>>>>>>>>> -- 
>>>>>>>>>  
>>>>>>>>>  
>>>>>>>>>  
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> -- 
>>>>>>>>  Paolo
>>>>>>>>  
>>>>>>>  -- 
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>  -- 
>>>>>  
>>>>>  
>>>>>  
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>>  Paolo 
>>>>
>>>  -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>>  Paolo 
>>
>

-- 



Reply via email to