openresty / openresty.org

Code and data for the openresty.org site
https://openresty.org
1.26k stars 290 forks source link

openresty see .css/.js as lua file #25

Open ovoshlook opened 8 years ago

ovoshlook commented 8 years ago

Hi. Lua module tries to enterpretate all css/js files as lua fies.

*95 failed to load external Lua file "/usr/local/openresty/nginx/html/mysite/themes/default/js/jquery-1.10.2.min.js":

My config

location ~^/mysite/(.+) { default_type text/html; lua_need_request_body on; lua_code_cache off; content_by_lua_file html/mysite/$1; index index.lua index.lp; } location ~* ^.+.(?:css|eot|js|json|png|svg|ttf|woff)$ { }

agentzh commented 8 years ago

@ovoshlook It's your responsibility to ensure that only valid Lua file paths are passed to content_by_lua_file. File name extensions never matter here. In your example you should put your second location before the 1st because the second should take precedence.

You can check out the openresty.org and openresty-survey web apps for real-world examples of mixing Lua powered locations and other static assets:

https://github.com/openresty/openresty.org

https://github.com/agentzh/openresty-survey