🔥 Sync 2026-11-17 02:49:06

This commit is contained in:
github-actions[bot] committed 2026-11-17 02:49:06 +08:00
1 parent 527da74d3e
commit 8fcc7fc0e9
73 files changed
+11702 -765

No files matched your search

@@ -0,0 +1,15 @@
# Managed by luci-app-nginx-console.
#
# Shared zones for the limit_req / limit_conn directives that the console can
# write into a server section. This file needs an http context, which is why
# it lives in conf.d as a .conf file: uci.conf.template ends its http block
# with "include conf.d/*.conf;". The .locations files in the same directory
# are included per server instead and cannot hold these.
#
# The console only ever references these zone names, so the rates are edited
# here rather than per section.
limit_req_zone $binary_remote_addr zone=ncs_rl_5:10m rate=5r/s;
limit_req_zone $binary_remote_addr zone=ncs_rl_20:10m rate=20r/s;
limit_req_zone $binary_remote_addr zone=ncs_rl_100:10m rate=100r/s;
limit_conn_zone $binary_remote_addr zone=ncs_cl:10m;
+37
View File
@@ -0,0 +1,37 @@
#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
#
# nginx-console - read-only backend for luci-app-nginx-console.
#
# This entry point only serves the commands that cannot change anything:
# status, test, logs, certs, backups list, auth list and audit. Everything
# that writes lives in nginx-console-write, so a session that is only
# granted the read ACL cannot reach it - rpcd checks the exec permission of
# the path it is asked to run, and this path is not in the write ACL.
#
# Every command prints exactly one JSON object on stdout and exits 0, so the
# caller never has to interpret exit codes.
. /usr/libexec/nginx-console-lib.sh
# cmd_auth serves both the read-only listing and the writes; in this entry
# point only the listing is allowed.
AUTH_MODE=ro
case "$1" in
status) cmd_status ;;
test) cmd_test ;;
logs) cmd_logs "$2" "$3" ;;
certs) cmd_certs ;;
backups) cmd_backups "$2" ;;
auth) cmd_auth "$2" "$3" ;;
audit) cmd_audit ;;
*) json_fail unknown_command ;;
esac
# Nothing of a finished transaction is left behind: the staged form input and
# the rollback snapshot both have a lifetime of one command. Dated copies for
# manual recovery live in $BACKUP_DIR instead.
rm -f "$PENDING" "$SNAPSHOT" 2>/dev/null
exit 0
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,54 @@
#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
#
# nginx-console-write - write backend for luci-app-nginx-console.
#
# Everything that changes the nginx configuration goes through this entry
# point: editing and adding server sections, installing and removing
# conf.d fragments, restoring a backup, installing uploaded certificates and
# managing the htpasswd users.
#
# The read-only commands live in nginx-console, which is the only path the
# read ACL grants exec on, so granting read access does not hand out the
# ability to rewrite the configuration.
#
# Every write is a transaction: back up, write, run `nginx -t`, roll back
# when the test fails, and reload only after the test passed.
#
# Every command prints exactly one JSON object on stdout and exits 0, so the
# caller never has to interpret exit codes.
. /usr/libexec/nginx-console-lib.sh
AUTH_MODE=rw
# A staged file can hold a plain text password. The page writes it 0600, but a
# pre-existing file keeps whatever mode it had (open(2) only applies the mode
# when creating), so it is tightened here before anything reads it.
for staged in /tmp/nginx-console.pending.*; do
[ -f "$staged" ] && chmod 0600 "$staged" 2>/dev/null
done
# Commands that read staged input take that file's path as their last argument
# ($3 for server-save/add, $2 for fragment/upload, $3 for auth). The staging
# path is validated in set_pending(); the page deletes its own file, and the
# removal below is only a backstop for a path this run adopted.
case "$1" in
server-save) cmd_server_save "$2" "$3" ;;
server-add) cmd_server_add "$2" "$3" ;;
server-delete) cmd_server_delete "$2" ;;
frag-save) cmd_frag_save "$2" "$3" ;;
frag-delete) cmd_frag_delete "$2" ;;
backup-restore) cmd_backup_restore "$2" ;;
upload) cmd_upload "$2" "$3" ;;
auth) cmd_auth "$2" "$3" "$4" ;;
*) json_fail unknown_command ;;
esac
# Nothing of a finished transaction is left behind: the staged form input and
# the rollback snapshot both have a lifetime of one command. Dated copies for
# manual recovery live in $BACKUP_DIR instead.
[ -n "$PENDING_PATH" ] && rm -f "$PENDING_PATH" 2>/dev/null
rm -f "$SNAPSHOT" 2>/dev/null
exit 0
@@ -0,0 +1,14 @@
{
"admin/services/nginx-console": {
"title": "Nginx 控制台",
"order": 62,
"action": {
"type": "view",
"path": "nginx-console/main"
},
"depends": {
"acl": [ "luci-app-nginx-console" ],
"uci": { "nginx": true }
}
}
}
@@ -0,0 +1,26 @@
{
"luci-app-nginx-console": {
"description": "Access to the nginx console: a read grant gets the read-only commands, a write grant also gets the commands that change the configuration",
"read": {
"file": {
"/usr/libexec/nginx-console": [ "exec" ],
"/etc/nginx/conf.d": [ "list" ],
"/etc/nginx/conf.d/*": [ "read", "list" ],
"/etc/nginx/certs": [ "list" ],
"/etc/nginx/certs/*": [ "read", "list" ],
"/etc/ssl/acme": [ "list" ],
"/etc/ssl/acme/*": [ "read", "list" ],
"/etc/acme": [ "list" ],
"/etc/acme/*": [ "read", "list" ],
"/etc/luci-uploads": [ "list" ],
"/etc/luci-uploads/*": [ "read", "list" ]
}
},
"write": {
"file": {
"/usr/libexec/nginx-console-write": [ "exec" ],
"/tmp/nginx-console.pending.*": [ "write", "read", "remove" ]
}
}
}
}