Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx 使用HttpLuaModule‎;向web客户端发送多个html文件;_Nginx_Lua - Fatal编程技术网

Nginx 使用HttpLuaModule‎;向web客户端发送多个html文件;

Nginx 使用HttpLuaModule‎;向web客户端发送多个html文件;,nginx,lua,Nginx,Lua,运行此脚本时,仅显示标题: ngx.exec('/header.html') ngx.exec('/footer.html') 提供我的模板的最佳方式是什么 我也试过: local f = io.read('/header.html','r') ngx.print(f) 但是我似乎无法通过404错误。您的描述不太清楚,但是 ngx.exec()允许您使用args访问位置。 如果要显示html文件,可以编写lua脚本并使用content\u by\u lua\u file命令 Nginx配置:

运行此脚本时,仅显示标题:

ngx.exec('/header.html')
ngx.exec('/footer.html')
提供我的模板的最佳方式是什么

我也试过:

local f = io.read('/header.html','r')
ngx.print(f)

但是我似乎无法通过404错误。

您的描述不太清楚,但是

ngx.exec()
允许您使用args访问位置。 如果要显示html文件,可以编写
lua
脚本并使用
content\u by\u lua\u file
命令

Nginx配置:

locaction /test {
    default_type "text/plain";
    content_by_lua_file "x.lua";
}
Lua脚本:

local ngx = require 'ngx'
local f = io.open('header.html', 'r')
local html_text = f:read()
ngx.print(html_text)
您可以通过nginx服务器访问
127.0.0.1/test

现在查看您的html文件。

您的描述不是很清楚,但是

ngx.exec()
允许您使用args访问位置。 如果要显示html文件,可以编写
lua
脚本并使用
content\u by\u lua\u file
命令

Nginx配置:

locaction /test {
    default_type "text/plain";
    content_by_lua_file "x.lua";
}
Lua脚本:

local ngx = require 'ngx'
local f = io.open('header.html', 'r')
local html_text = f:read()
ngx.print(html_text)
您可以通过nginx服务器访问
127.0.0.1/test
现在查看您的html文件。

我还认为ngx.say()比ngx.print()好。我还认为ngx.say()比ngx.print()好。