我正在尝试创建一个条件content_by_lua脚本,其中的内容应该只在一个条件下由lua设置。
示例:
location / {
content_by_lua_file /nginx/lua/nginx.lua;
root /nginx/www;
index index.html;
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff|ttf)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
if condition then
ngx.header["Content-type"] = "text/html"
ngx.say('<H1>Hello World.</H1>');
ngx.exit(0)
else
-- serve the original content (index.html)
end
问题是 - 在nginx下的lua脚本在同一路由中不支持2内容指令,我可以做一个解决方法吗?
当条件为false时使用当前用法我希望显示index.html但是接收空白页面
答案 0 :(得分:1)
您可以拨打roll_btn.addEventListener(MouseEvent.CLICK, rollDice);
function rollDice(event:MouseEvent):void
{
var die1:uint = Math.floor(Math.random() * 6);
var die2:uint = Math.floor(Math.random() * 6);
var diceTotal:uint = die1 + die2;
die1_txt.text = die1.toString();
die2_txt.text = die2.toString();
status_txt.text = "You rolled "+diceTotal;
// ...
}
来拨打内部电话。
<强> nginx.conf 强>
ngx.exec
<强> nginx.lua 强>
location / {
content_by_lua_file /nginx/lua/nginx.lua;
root /nginx/www;
index index.html;
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff|ttf)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
location /default_index {
root /nginx/www;
index index.html;
}