Compare commits
No commits in common. "main" and "2024-01-21" have entirely different histories.
main
...
2024-01-21
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@ -26,16 +26,15 @@ jobs:
|
|||||||
cd /opt/openwrt-sdk*/bin/packages/aarch64_generic/base
|
cd /opt/openwrt-sdk*/bin/packages/aarch64_generic/base
|
||||||
ls
|
ls
|
||||||
mv *.ipk luci-app-caddy_all.ipk
|
mv *.ipk luci-app-caddy_all.ipk
|
||||||
echo "build_time=$(date '+%Y年%m月%d日%H:%M:%S' | jq -sRr @uri)" >> $GITHUB_ENV
|
echo "build_time=$(date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
|
||||||
echo "tag=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
|
echo "tag=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
|
||||||
- name: 发布
|
- name: 发布
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.c8 }}
|
token: ${{ secrets.c8 }}
|
||||||
body: |
|
body: |
|
||||||
> ### 
|
> ### 编译时间 :${{ env.build_time }}
|
||||||
|
|
||||||
二进制程序下载地址:[caddy](https://github.com/lmq8267/caddy/releases)
|
|
||||||
|
|
||||||
tag_name: ${{ env.tag }}
|
tag_name: ${{ env.tag }}
|
||||||
files: /opt/openwrt-sdk*/bin/packages/aarch64_generic/base/*
|
files: /opt/openwrt-sdk*/bin/packages/aarch64_generic/base/*
|
||||||
|
24
README.md
24
README.md
@ -1,26 +1,11 @@
|
|||||||
# luci-app-caddy
|
# luci-app-caddy
|
||||||
<p align="center">
|
|
||||||
<img alt="GitHub Created At" src="https://img.shields.io/github/created-at/lmq8267/luci-app-caddy?logo=github&label=%E5%88%9B%E5%BB%BA%E6%97%A5%E6%9C%9F">
|
|
||||||
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Flmq8267%2Fluci-app-caddy&count_bg=%2395C10D&title_bg=%23555555&icon=github.svg&icon_color=%238DC409&title=%E8%AE%BF%E9%97%AE%E6%95%B0&edge_flat=false"/></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/releases"><img src="https://img.shields.io/github/downloads/lmq8267/luci-app-caddy/total?logo=github&label=%E4%B8%8B%E8%BD%BD%E9%87%8F"></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/graphs/contributors"><img src="https://img.shields.io/github/contributors-anon/lmq8267/luci-app-caddy?logo=github&label=%E8%B4%A1%E7%8C%AE%E8%80%85"></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/releases/"><img src="https://img.shields.io/github/release/lmq8267/luci-app-caddy?logo=github&label=%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC"></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/issues"><img src="https://img.shields.io/github/issues-raw/lmq8267/luci-app-caddy?logo=github&label=%E9%97%AE%E9%A2%98"></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/discussions"><img src="https://img.shields.io/github/discussions/lmq8267/luci-app-caddy?logo=github&label=%E8%AE%A8%E8%AE%BA"></a>
|
|
||||||
<a href="GitHub repo size"><img src="https://img.shields.io/github/repo-size/lmq8267/luci-app-caddy?logo=github&label=%E4%BB%93%E5%BA%93%E5%A4%A7%E5%B0%8F"></a>
|
|
||||||
<a href="https://github.com/lmq8267/luci-app-caddy/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/actions/workflow/status/lmq8267/luci-app-caddy/build.yml?branch=main&logo=github&label=%E6%9E%84%E5%BB%BA%E7%8A%B6%E6%80%81" alt="Build status"></a>
|
|
||||||
|
|
||||||
项目地址:https://github.com/caddyserver/caddy
|
项目地址:https://github.com/caddyserver/caddy
|
||||||
|
|
||||||
没有添加caddy二进制程序,需要下载或编译对应cpu架构的二进制程序手动上传至路由器,然后填写对应的程序路径。
|
没有添加caddy二进制程序,需要下载或编译对应cpu架构的二进制程序手动上传至路由器,然后填写对应的程序路径。
|
||||||
caddy的大概 [命令参数](https://github.com/lmq8267/caddy/blob/main/README_caddy.md)
|
|
||||||
```shell
|
|
||||||
#查看添加了哪些插件命令
|
|
||||||
caddy list-modules -s
|
|
||||||
```
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
编译的大概步骤:抄自网上的方法, 也有我编译好的二进制文件[caddy](https://github.com/lmq8267/caddy/releases)文件服务器支持照片音视频预览播放 支持markdown[UI预览效果图](https://github.com/lmq8267/caddy/tree/main#ui%E9%A2%84%E8%A7%88)
|
编译的大概步骤:抄自网上的方法
|
||||||
还有OpenWrt的[github.com/fuqiang03/openwrt-caddy](https://github.com/fuqiang03/openwrt-caddy)Makefile
|
|
||||||
```shell
|
```shell
|
||||||
apt update
|
apt update
|
||||||
apt install xcaddy git libnss3 upx-ucl
|
apt install xcaddy git libnss3 upx-ucl
|
||||||
@ -53,8 +38,3 @@ upx --lzma --best caddy
|
|||||||
|
|
||||||
其他功能可以自行修改编辑配置文件
|
其他功能可以自行修改编辑配置文件
|
||||||

|

|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
|
63
caddy/Makefile
Normal file
63
caddy/Makefile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Copyright (C) 2010-2020 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=caddy
|
||||||
|
PKG_VERSION:=$(shell curl -L -k -s https://github.com/caddyserver/caddy/releases/latest | grep 'tag_name' | cut -d\" -f4 | tr -d ' v')
|
||||||
|
ifeq ($(PKG_VERSION),)
|
||||||
|
PKG_VERSION:=2.7.6
|
||||||
|
endif
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com//caddyserver/caddy/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=skip
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
GO_PKG:=github.com/caddyserver/caddy/v2
|
||||||
|
GO_PKG_BUILD_PKG:=$(GO_PKG)/caddy
|
||||||
|
GO_PKG_LDFLAGS:=-s -w
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
TITLE:=Caddy2 is an open source web server
|
||||||
|
URL:=https://caddyserver.com
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
DEPENDS:=$(GO_ARCH_DEPENDS) +libpthread
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Still the only web server to use TLS automatically and by default. Deploy and scale HTTPS effortlessly with Caddy2.
|
||||||
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
$(call Build/Prepare/Default)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(eval GO_PKG_BUILD_PKG:=$(GO_PKG)/cmd/caddy)
|
||||||
|
$(call GoPackage/Build/Configure)
|
||||||
|
$(call GoPackage/Build/Compile)
|
||||||
|
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/caddy
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/tmp
|
||||||
|
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/caddy $(1)/tmp/caddy
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,$(PKG_NAME)))
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
28
caddy/README.md
Normal file
28
caddy/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
通过这个构建的二进制程序 不能开启webdav 会导致启动失败,而单独构建的添加了webdav模块的可以开启webdav
|
||||||
|
所以最好是单独编译
|
||||||
|
```shell
|
||||||
|
GOOS=linux GOARCH=mipsle GOMIPS=softfloat ~/go/bin/xcaddy build \
|
||||||
|
--with github.com/mholt/caddy-webdav \
|
||||||
|
--with github.com/aksdb/caddy-cgi/v2
|
||||||
|
```
|
||||||
|
|
||||||
|
在51行添加了upx压缩用来节省体积
|
||||||
|
```shell
|
||||||
|
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/caddy
|
||||||
|
|
||||||
|
$(STAGING_DIR_HOST)/bin/upx 对应的是编译器的 openwrt-sdk-版本-架构名_gcc-版本号_musl.Linux-x86_64/staging_dir/host/bin目录里
|
||||||
|
如果这个目录没有这个upx 可以改为其他目录 如 /usr/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/caddy
|
||||||
|
都没有可以安装也可以下载https://github.com/upx/upx/releases二进制
|
||||||
|
```
|
||||||
|
|
||||||
|
在55-56行
|
||||||
|
```shell
|
||||||
|
$(INSTALL_DIR) $(1)/tmp
|
||||||
|
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/caddy $(1)/tmp/caddy
|
||||||
|
```
|
||||||
|
|
||||||
|
设置安装在/tmp/caddy了 , 如果你路由器闪存空间足够,可改为/usr/bin/caddy
|
||||||
|
```shell
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/caddy $(1)/usr/bin/caddy
|
||||||
|
```
|
@ -16,7 +16,6 @@ function index()
|
|||||||
entry({"admin", "nas", "caddy", "caddy_status"}, call("caddy_status")).leaf = true
|
entry({"admin", "nas", "caddy", "caddy_status"}, call("caddy_status")).leaf = true
|
||||||
entry({"admin", "nas", "caddy", "get_log"}, call("get_log")).leaf = true
|
entry({"admin", "nas", "caddy", "get_log"}, call("get_log")).leaf = true
|
||||||
entry({"admin", "nas", "caddy", "clear_log"}, call("clear_log")).leaf = true
|
entry({"admin", "nas", "caddy", "clear_log"}, call("clear_log")).leaf = true
|
||||||
entry({"admin", "nas", "caddy", "admin_info"}, call("admin_info")).leaf = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function caddy_status()
|
function caddy_status()
|
||||||
@ -31,8 +30,8 @@ function caddy_status()
|
|||||||
local tagcontent = tagfile:read("*all")
|
local tagcontent = tagfile:read("*all")
|
||||||
tagfile:close()
|
tagfile:close()
|
||||||
if tagcontent and tagcontent ~= "" then
|
if tagcontent and tagcontent ~= "" then
|
||||||
os.execute("start_time=$(cat /tmp/caddy_time) && time=$(($(date +%s)-start_time)) && day=$((time/86400)) && [ $day -eq 0 ] && day='' || day=${day}天 && time=$(date -u -d @${time} +'%H小时%M分%S秒') && echo $day $time > /tmp/command_caddy 2>&1")
|
os.execute("start_time=$(cat /tmp/caddy_time) && time=$(($(date +%s)-start_time)) && day=$((time/86400)) && [ $day -eq 0 ] && day='' || day=${day}天 && time=$(date -u -d @${time} +'%H小时%M分%S秒') && echo $day $time > /tmp/command_output 2>&1")
|
||||||
local command_output_file = io.open("/tmp/command_caddy", "r")
|
local command_output_file = io.open("/tmp/command_output", "r")
|
||||||
if command_output_file then
|
if command_output_file then
|
||||||
e.caddysta = command_output_file:read("*all")
|
e.caddysta = command_output_file:read("*all")
|
||||||
command_output_file:close()
|
command_output_file:close()
|
||||||
@ -82,10 +81,3 @@ function clear_log()
|
|||||||
luci.sys.call("cat /dev/null > $(uci -q get caddy.@caddy[0].log_dir)")
|
luci.sys.call("cat /dev/null > $(uci -q get caddy.@caddy[0].log_dir)")
|
||||||
end
|
end
|
||||||
|
|
||||||
function admin_info()
|
|
||||||
local validate = luci.sys.exec("$(uci -q get caddy.@caddy[0].bin_dir) validate --config /etc/caddy/Caddyfile --adapter caddyfile 2>&1")
|
|
||||||
|
|
||||||
luci.http.prepare_content("application/json")
|
|
||||||
luci.http.write_json({ validate = validate })
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -11,15 +11,6 @@ o = s:option(Flag, "enabled", translate("Enabled"))
|
|||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
o.default = 0
|
o.default = 0
|
||||||
|
|
||||||
o = s:option(Button, "btnrm", translate("重启"))
|
|
||||||
o.inputtitle = translate("重启")
|
|
||||||
o.description = translate("在没有修改参数的情况下快速重新启动一次")
|
|
||||||
o.inputstyle = "apply"
|
|
||||||
o:depends("enabled", "1")
|
|
||||||
o.write = function()
|
|
||||||
os.execute("/etc/init.d/caddy restart")
|
|
||||||
end
|
|
||||||
|
|
||||||
e=s:option(ListValue,"cmd",translate("启动方式"),
|
e=s:option(ListValue,"cmd",translate("启动方式"),
|
||||||
translate("自定义配置文件启动,若不懂参数请勿选择自定义"))
|
translate("自定义配置文件启动,若不懂参数请勿选择自定义"))
|
||||||
e:value("默认")
|
e:value("默认")
|
||||||
@ -118,10 +109,4 @@ o.rmempty = false
|
|||||||
o = s:option(Flag, "api", translate("启用 API接口"))
|
o = s:option(Flag, "api", translate("启用 API接口"))
|
||||||
o:depends("cmd", "默认")
|
o:depends("cmd", "默认")
|
||||||
|
|
||||||
o = s:option(Button, "admin_info", translate("检测配置文件"),
|
|
||||||
translate("验证Caddyfile配置文件是否正确,它会模拟启动caddy<br>但是并不会真的启动,会列出详细信息,以便修正配置文件"))
|
|
||||||
|
|
||||||
o.rawhtml = true
|
|
||||||
o.template = "caddy/admin_info"
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
<%+cbi/valueheader%>
|
|
||||||
<script type="text/javascript">//<![CDATA[
|
|
||||||
function admin_info(btn)
|
|
||||||
{
|
|
||||||
btn.disabled = true;
|
|
||||||
btn.value = '<%:Collecting data...%>';
|
|
||||||
XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "caddy", "admin_info")%>',
|
|
||||||
null,
|
|
||||||
function(x,rv)
|
|
||||||
{
|
|
||||||
var tb = document.getElementById('<%=self.option%>-status');
|
|
||||||
if (tb) {
|
|
||||||
rv.validate = rv.validate.replace(/{"level":/g, '<br>{"level":').replace(/Error/g, "<br>Error").replace(/Valid configuration/g, "<br><strong><font color='#008000'>当前配置文件正确!</font></strong>").replace(/warn/g, "<font color='#800080'>警告</font>").replace(/level/g, "<font color='#1E90FF'>等级</font>").replace(/info/g, "<font color='#00BFFF'>普通</font>").replace(/msg/g, "<font color='#FFA500'>信息</font>").replace(/error/g, "<font color='#DB7093'>错误</font>").replace(/Error:/g, "<font color='red'><strong>当前配置文件错误!</strong><br>错误位置信息:</font>");
|
|
||||||
tb.innerHTML = "<br><font color='#FF00FF'><%:状态:%></font>" + "<font color='#2F4F4F'>" + rv.validate + "</font>";
|
|
||||||
}
|
|
||||||
btn.disabled = false;
|
|
||||||
btn.value = '<%:检测%>';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//]]></script>
|
|
||||||
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:检测%>" onclick="return admin_info(this)" />
|
|
||||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
|
||||||
<%+cbi/valuefooter%>
|
|
@ -14,8 +14,8 @@
|
|||||||
var tb = document.getElementById('caddy_status');
|
var tb = document.getElementById('caddy_status');
|
||||||
if (st && tb) {
|
if (st && tb) {
|
||||||
|
|
||||||
var caddyStatus = st.running ? "<span style='color:green;'> 运行中</span><img src='https://www.right.com.cn/forum/data/attachment/album/202401/30/073058is17bcmu7z3nmn2b.gif' width='30px' alt=''>" : "<span style='color:red;'> 未运行</span>";
|
var caddyStatus = st.running ? "<span style='color:green;'> 运行中</span>" : "<span style='color:red;'> 未运行</span>";
|
||||||
var caddystaContent = st.running ? "已运行:" + "<span style='color:#DA70D6;'>" + st.caddysta + "</span>" : "";
|
var caddystaContent = st.running ? " " + " 已 运 行:" + "<span style='color:#DA70D6;'>" + st.caddysta + "</span>" : "";
|
||||||
var caddycpuContent = st.running ? "<br>" + "CPU占用:" + "<span style='color:#6A5ACD;'>" + st.caddycpu + "</span>" : "";
|
var caddycpuContent = st.running ? "<br>" + "CPU占用:" + "<span style='color:#6A5ACD;'>" + st.caddycpu + "</span>" : "";
|
||||||
var caddyramContent = st.running ? " " + " 内存占用:" + "<span style='color:#0000CD;'>" + st.caddyram + "</span>" : "";
|
var caddyramContent = st.running ? " " + " 内存占用:" + "<span style='color:#0000CD;'>" + st.caddyram + "</span>" : "";
|
||||||
var caddytagContent = st.running ? "<br>" + "当前版本:" + "<span style='color:#CD853F;'>" + st.caddytag + "</span>" : "";
|
var caddytagContent = st.running ? "<br>" + "当前版本:" + "<span style='color:#CD853F;'>" + st.caddytag + "</span>" : "";
|
||||||
|
@ -20,6 +20,11 @@ admin $2a$14$RdbOHzJhf5BaapSdlYTCbe.yWY9cEZjyDpfgwStY28K/qsM1tX8tu
|
|||||||
root * /mnt
|
root * /mnt
|
||||||
#文件服务器 端口12311
|
#文件服务器 端口12311
|
||||||
file_server browse
|
file_server browse
|
||||||
|
|
||||||
|
header {
|
||||||
|
#中文字符显示
|
||||||
|
Content-Type "text/plain; charset=utf-8"
|
||||||
|
}
|
||||||
|
|
||||||
log {
|
log {
|
||||||
#日志 路径/tmp/caddy/requests.log
|
#日志 路径/tmp/caddy/requests.log
|
||||||
|
@ -63,7 +63,7 @@ start_service() {
|
|||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
chmod +x $PROG
|
chmod +x $PROG
|
||||||
if [[ "$($PROG -h 2>&1 | wc -l)" -lt 3 ]] ;then
|
if [ $(($($PROG -h | wc -l))) -lt 3 ] ;then
|
||||||
uci -q set caddy.@caddy[0].enabled=0
|
uci -q set caddy.@caddy[0].enabled=0
|
||||||
uci commit caddy
|
uci commit caddy
|
||||||
echo "$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X) : $PROG 程序不完整或CPU架构不支持的程序,无法启动!" >>$log_dir 2>&1
|
echo "$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X) : $PROG 程序不完整或CPU架构不支持的程序,无法启动!" >>$log_dir 2>&1
|
||||||
@ -138,6 +138,10 @@ $filezips
|
|||||||
$filebasicauth
|
$filebasicauth
|
||||||
root * $data_dir
|
root * $data_dir
|
||||||
file_server browse
|
file_server browse
|
||||||
|
|
||||||
|
header {
|
||||||
|
Content-Type "text/plain; charset=utf-8"
|
||||||
|
}
|
||||||
|
|
||||||
$logs
|
$logs
|
||||||
|
|
||||||
@ -161,7 +165,6 @@ logpath="$(echo $caddyf | grep "output file" | awk -F 'output file' '{print $2}'
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
$PROG fmt --overwrite $caddy_file
|
|
||||||
procd_open_instance caddy
|
procd_open_instance caddy
|
||||||
procd_set_param command $PROG
|
procd_set_param command $PROG
|
||||||
procd_append_param command run
|
procd_append_param command run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user