Mercurial Hosting > luan
changeset 2158:b235600ea89b nginx_sites_addon tip
add nginx_default_conf
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 27 Jan 2026 21:50:37 -0700 |
| parents | 484d2b42f2d1 |
| children | |
| files | host/test/test_https.luan src/luan/host/Https.luan src/luan/host/update.luan |
| diffstat | 3 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/host/test/test_https.luan Tue Jan 27 19:51:41 2026 -0800 +++ b/host/test/test_https.luan Tue Jan 27 21:50:37 2026 -0700 @@ -13,8 +13,9 @@ local domain = "https.me.luan.software" local site_dir = uri("file:local") local luanhost_dir = uri("file:..") +local nginx_default_conf = uri("file:../local/nginx.default.conf") local dry_run = true site_dir.mkdir() -Https.do_set_https(is_https,domain,site_dir,luanhost_dir,dry_run) +Https.do_set_https(is_https,domain,site_dir,luanhost_dir,nginx_default_conf,dry_run)
--- a/src/luan/host/Https.luan Tue Jan 27 19:51:41 2026 -0800 +++ b/src/luan/host/Https.luan Tue Jan 27 21:50:37 2026 -0700 @@ -71,7 +71,7 @@ -- for testing Https.delete_junk = delete_junk -local function nginx_ssl_conf(domain,files,luanhost_dir) +local function nginx_ssl_conf(domain,files,nginx_default_conf) %> server { server_name <%=domain%>; @@ -99,7 +99,7 @@ ssl_certificate <%= files.local_cer_file.canonical().to_string() %>; ssl_certificate_key <%= files.key_file.canonical().to_string() %>; - include <%= luanhost_dir.canonical().to_string() %>/local/nginx.default.conf; + include <%= nginx_default_conf.canonical().to_string() %>; } <% end @@ -171,17 +171,17 @@ local ssl_renewal_period = Time.period{days=30} -function Https.update(domain,site_dir,luanhost_dir) +function Https.update(domain,site_dir,nginx_default_conf) local files = get_files(domain,site_dir) if files.nginx_file.exists() then -- sys_logger.info("update "..domain) - local nginx = ` nginx_ssl_conf(domain,files,luanhost_dir) ` + local nginx = ` nginx_ssl_conf(domain,files,nginx_default_conf) ` files.nginx_file.write(nginx) end delete_junk(domain,site_dir) end -local function do_set_https(is_https,domain,site_dir,luanhost_dir,dry_run) +local function do_set_https(is_https,domain,site_dir,luanhost_dir,nginx_default_conf,dry_run) local files = get_files(domain,site_dir) -- luan/host @@ -253,7 +253,7 @@ -- the nginx config only requires 2 files: -- fullchain.cer and DOMAIN.key logger.info("writing nginx conf to "..files.nginx_file.canonical().to_string()) - local nginx = ` nginx_ssl_conf(domain,files,luanhost_dir) ` + local nginx = ` nginx_ssl_conf(domain,files,nginx_default_conf) ` files.nginx_file.write(nginx) reload_nginx(luanhost_dir_str) end @@ -288,13 +288,14 @@ local domain = Http.domain local site_dir = uri("site:").parent() local luanhost_dir = uri("file:.") + local nginx_default_conf = uri("file:local/nginx.default.conf") -- use for testing, so as to not hit rate limits -- on the real letsencrypt servers local dry_run = false if not try_synchronized( function() - do_set_https(is_https,domain,site_dir,luanhost_dir,dry_run) + do_set_https(is_https,domain,site_dir,luanhost_dir,nginx_default_conf,dry_run) end, domain..".lock", 0 )() then logger.info("set_https already running for "..domain..", skipping") end
--- a/src/luan/host/update.luan Tue Jan 27 19:51:41 2026 -0800 +++ b/src/luan/host/update.luan Tue Jan 27 21:50:37 2026 -0700 @@ -5,12 +5,12 @@ local Https = require "classpath:luan/host/Https.luan" -local luanhost_dir = Io.schemes.file(".").canonical() -local sites_dir = luanhost_dir.child("sites") +local nginx_default_conf = Io.schemes.file("local/nginx.default.conf").canonical() +local sites_dir = Io.schemes.file("sites") sites_dir.mkdir() local children = sites_dir.children() for _, site_dir in ipairs(children) do local domain = site_dir.name() - Https.update(domain, site_dir, luanhost_dir) + Https.update(domain, site_dir, nginx_default_conf) end
