lighttpd配置选项
1 添加模块
server.modules += ( "mod_proxy",
"mod_evasive",
"mod_fastcgi",
"mod_setenv",
"mod_access" )
2 配置fastcgi
fastcgi.server += ("/api" =>
((
"bin-path" => "/tmp/server",
"max-procs" => 1,
"socket" => "/tmp/connection.socket",
"check-local" => "disable",
"allow-x-send-file" => "enable"
)))
-
bin-path:指定fastcgi程序所在的路径
-
max-procs:最大进程数
-
socket:lighttpd与fastcgi交互的socket
3 配置根目录和端口
server.stream-response-body = 1
server.document-root = "/var/www/html"
server.port=8090
-
server.stream-response-body:详见3.1章节
-
server.document-root:服务器的根目录,是lighttpd的核心配置项。可存放静态文件和动态请求转发的文件
-
server.port:配置lighttpd的监听端口
3.1 响应体传输方式
lighttpd的传输方式是由server.stream-response-body配置项决定的。
| 参数值 | 行为 |
|---|---|
0 |
关闭流式传输:Lighttpd 会等待后端生成完整的响应体,缓存到内存或临时文件后,再发送给客户端。 |
1 |
智能流式传输(默认):Lighttpd 根据响应头(如 Content-Length)和传输速度自动选择流式或缓冲模式。 |
2 |
强制流式传输:无论响应大小,Lighttpd 会立即将接收到的数据块发送给客户端,适用于大文件或实时 |
可以开启全局配置或者根据文件类型决定传输方式:
# 对大文件(如超过 10MB)强制流式传输
$HTTP["url"] =~ "\.(mp4|zip|iso)$" {
server.stream-response-body = 2
server.range-requests = "enable" # 启用断点续传
}
4 配置反向代理
# /redfish 路径代理规则
$HTTP["url"] =~ "^/restful" {
proxy.server = (
"" => (
( "host" => "127.0.0.1", "port" => 9080 )
)
)
server.errorfile-prefix = "/usr/local/redfish/restful_error_"
evasive.max-conns-per-ip = 10
}
- server.errorfile-prefix:定义错误文件页面的前缀。
-
404 错误会使用
/usr/local/redfish/redfish_error_404.html -
500 错误会使用
/usr/local/redfish/redfish_error_500.html

浙公网安备 33010602011771号