1
This commit is contained in:
@@ -6,6 +6,9 @@ server {
|
|||||||
ssl_certificate /etc/letsencrypt/live/ai.sggai.site/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/ai.sggai.site/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/ai.sggai.site/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/ai.sggai.site/privkey.pem;
|
||||||
|
|
||||||
|
error_log /usr/local/openresty/nginx/logs/ai.sggai.site.error.log notice;
|
||||||
|
error_log /dev/stderr notice;
|
||||||
|
|
||||||
location ^~ /.well-known/acme-challenge/ {
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
root /var/www;
|
root /var/www;
|
||||||
default_type text/plain;
|
default_type text/plain;
|
||||||
@@ -82,6 +85,16 @@ server {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cjson = require "cjson.safe"
|
local cjson = require "cjson.safe"
|
||||||
|
local short_post_log = {
|
||||||
|
method = ngx.req.get_method(),
|
||||||
|
uri = ngx.var.request_uri,
|
||||||
|
content_length = content_length,
|
||||||
|
content_type = ngx.var.http_content_type,
|
||||||
|
user_agent = ngx.var.http_user_agent,
|
||||||
|
body = body
|
||||||
|
}
|
||||||
|
ngx.log(ngx.NOTICE, "[ai.sggai.site] short POST request: ", cjson.encode(short_post_log) or body)
|
||||||
|
|
||||||
local payload = cjson.decode(body)
|
local payload = cjson.decode(body)
|
||||||
if type(payload) ~= "table" or payload.stream ~= false then
|
if type(payload) ~= "table" or payload.stream ~= false then
|
||||||
return ngx.exec(backend)
|
return ngx.exec(backend)
|
||||||
@@ -104,16 +117,6 @@ server {
|
|||||||
return ngx.exec(backend)
|
return ngx.exec(backend)
|
||||||
end
|
end
|
||||||
|
|
||||||
local matched_request_log = {
|
|
||||||
method = ngx.req.get_method(),
|
|
||||||
uri = ngx.var.request_uri,
|
|
||||||
content_length = content_length,
|
|
||||||
content_type = ngx.var.http_content_type,
|
|
||||||
user_agent = ngx.var.http_user_agent,
|
|
||||||
body = body
|
|
||||||
}
|
|
||||||
ngx.log(ngx.ERR, "[ai.sggai.site] matched short POST request: ", cjson.encode(matched_request_log) or body)
|
|
||||||
|
|
||||||
ngx.status = ngx.HTTP_OK
|
ngx.status = ngx.HTTP_OK
|
||||||
ngx.header["Content-Type"] = "application/json; charset=utf-8"
|
ngx.header["Content-Type"] = "application/json; charset=utf-8"
|
||||||
ngx.say([[{
|
ngx.say([[{
|
||||||
|
|||||||
14
reload.sh
14
reload.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Validate config, then reload OpenResty after conf changes.
|
# 修改配置后先校验,再重载 OpenResty。
|
||||||
|
|
||||||
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||||
|
|
||||||
@@ -9,18 +9,18 @@ cd "$ROOT_DIR"
|
|||||||
|
|
||||||
. "$ROOT_DIR/scripts/lib-compose.sh"
|
. "$ROOT_DIR/scripts/lib-compose.sh"
|
||||||
|
|
||||||
echo "Validating Docker Compose configuration..."
|
echo "正在校验 Docker Compose 配置..."
|
||||||
compose config >/dev/null
|
compose config >/dev/null
|
||||||
|
|
||||||
echo "Validating OpenResty configuration..."
|
echo "正在校验 OpenResty 配置..."
|
||||||
compose exec -T openresty openresty -t
|
compose exec -T openresty openresty -t
|
||||||
|
|
||||||
echo "Reloading OpenResty..."
|
echo "正在重载 OpenResty..."
|
||||||
if compose exec -T openresty openresty -s reload; then
|
if compose exec -T openresty openresty -s reload; then
|
||||||
echo "OpenResty reloaded."
|
echo "OpenResty 已重载。"
|
||||||
else
|
else
|
||||||
echo "Reload failed; restarting OpenResty..."
|
echo "重载失败,正在重启 OpenResty..."
|
||||||
compose restart openresty
|
compose restart openresty
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done."
|
echo "完成。"
|
||||||
|
|||||||
Reference in New Issue
Block a user