From 78944fffed51306762c335cbd7c6e16170dad9e3 Mon Sep 17 00:00:00 2001 From: Clifton Palmer Date: Mon, 28 Aug 2023 04:49:53 -0500 Subject: [PATCH] Updated publish with FQDN override --- docker-compose.yml | 2 +- lua/publish.lua | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e793fa4..96979c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: environment: - PUBLIC_ROOT_DIR=/storage - PUBLIC_LINK_DIR=/usr/local/apache2/htdocs - - PUBLIC_FQDN_OVERRIDE=https://public.purplebirdman.com +# - PUBLIC_FQDN_OVERRIDE=https://public.purplebirdman.com ports: - 80:80 volumes: diff --git a/lua/publish.lua b/lua/publish.lua index 5fa18c0..a132c70 100644 --- a/lua/publish.lua +++ b/lua/publish.lua @@ -25,9 +25,13 @@ function handle(r) if pattern then local nonce = publish(r.context_document_root, pattern) - local uri = ("%s://%s:%s/%s"):format( - r.is_https and "https" or "http", - r.server_name, r.port, nonce) + + -- if FQDN override is set, + -- use override instead of my own server name and port number + local fqdn = os.getenv('PUBLIC_FQDN_OVERRIDE') + fqdn = fqdn or (r.is_https and "https" or "http") .. "://" .. r.server_name .. ":" ..r.port + + local uri = ("%s/%s"):format(fqdn, nonce) r:puts( ([[%s]]):format(uri, uri) ) else local template = get_form(r.context_document_root) -- 2.47.2