tgbyte/lighttpdLighttpd(发音"lighty")是一款开源轻量级Web服务器,专注于高性能与低资源消耗。作为Docker镜像,它提供了快速部署、环境隔离和配置灵活的优势,无需手动编译安装即可在任何Docker环境中运行,确保部署一致性。
bashdocker run -d --name lighttpd -p 80:80 lighttpd
-d:后台运行容器--name lighttpd:指定容器名称-p 80:80:映射主机80端口到容器80端口lighttpd:默认使用官方最新镜像bashdocker run -d --name lighttpd -p 80:80 -v /path/to/local/files:/var/www/localhost/htdocs lighttpd
将主机
/path/to/local/files目录挂载为容器文档根目录,替换/path/to/local/files为实际路径
bashdocker run -d --name lighttpd -p 80:80 \ -v /path/to/lighttpd.conf:/etc/lighttpd/lighttpd.conf \ -v /path/to/static:/var/www/localhost/htdocs \ lighttpd
创建docker-compose.yml:
yamlversion: '3' services: lighttpd: image: lighttpd container_name: lighttpd ports: - "80:80" # HTTP端口 - "443:443" # HTTPS端口(如需启用) volumes: - ./static:/var/www/localhost/htdocs # 静态文件目录 - ./lighttpd.conf:/etc/lighttpd/lighttpd.conf # 自定义配置 - ./ssl:/etc/lighttpd/ssl # SSL证书目录(HTTPS用) restart: unless-stopped # 异常退出时自动重启
启动服务:
bashdocker-compose up -d
默认路径:/etc/lighttpd/lighttpd.conf,关键配置项:
| 配置项 | 说明 | 默认值 |
|---|---|---|
server.port | 监听端口 | 80 |
server.document-root | 文档根目录 | /var/www/localhost/htdocs |
server.modules | 加载模块列表 | ("mod_access", "mod_alias") |
index-file.names | 默认索引文件 | ("index.html", "index.htm") |
server.errorlog | 错误日志路径 | /var/log/lighttpd/error.log |
accesslog.filename | 访问日志路径 | /var/log/lighttpd/access.log |
server.crt和server.key),合并为server.pem(证书在前,密钥在后)/etc/lighttpd/ssllighttpd.conf添加HTTPS配置:confserver.modules += ( "mod_openssl" ) $SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/etc/lighttpd/ssl/server.pem" # 合并的证书文件 ssl.ca-file = "/etc/lighttpd/ssl/ca.crt" # CA证书(可选) server.name = "example.com" server.document-root = "/var/www/localhost/htdocs" }
转发请求至后端Node.js服务(运行在[***]):
confserver.modules += ( "mod_proxy" ) proxy.server = ( "/" => ( ( "host" => "backend", # 后端服务地址(需与容器同网络) "port" => 3000 # 后端服务端口 ) ) )
-v挂载主机目录,避免容器删除导致数据丢失mod_webdav)


manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务