openresty.org icon indicating copy to clipboard operation
openresty.org copied to clipboard

openresty see .css/.js as lua file

Open ovoshlook opened this issue 9 years ago • 1 comments

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)$ { }

ovoshlook avatar Mar 27 '16 06:03 ovoshlook

@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

agentzh avatar Mar 27 '16 17:03 agentzh