Mercurial Hosting > luan
changeset 2129:6a2383baecb6
integrate into system nginx
| author | Violet7 |
|---|---|
| date | Fri, 16 Jan 2026 15:30:49 -0800 |
| parents | cfe173c8e104 |
| children | aaf2795f4ed8 |
| files | host/doc/install.txt host/start.sh host/start_nginx.sh host/startup/nginx/nginx.conf.luan host/startup/nginx/nginx.default.conf.luan host/stop.sh host/stop_nginx.sh host/update2.sh src/luan/host/Https.luan |
| diffstat | 9 files changed, 24 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/host/doc/install.txt Thu Jan 15 21:30:07 2026 -0800 +++ b/host/doc/install.txt Fri Jan 16 15:30:49 2026 -0800 @@ -30,7 +30,18 @@ 7) compile ./update.sh -8) open in browser http://me.luan.software:8080 +8) Configure nginx + nginx config can exist in many places, on old macOS it is usually /usr/local/etc/nginx/nginx.conf + can also exist at /usr/local/nginx/conf/nginx.conf or /etc/nginx/nginx.conf + + add this line inside the `http` block + include /Users/administrator/luan/host/local/nginx.conf; + + if nginx provides a default server, it conflicts with the luanhost one. remove or disable it. + on old macOS this usually does not exist and this step is not needed + sudo rm -r /etc/nginx/sites-enabled/default + +9) open in browser http://me.luan.software:8080 Install on production/test machine: 1 - 7 same
--- a/host/start.sh Thu Jan 15 21:30:07 2026 -0800 +++ b/host/start.sh Fri Jan 16 15:30:49 2026 -0800 @@ -9,7 +9,7 @@ mkdir -p logs 2>/dev/null; touch started.lock; -sudo $(which nginx) -c $(pwd)/local/nginx.conf; +./start_nginx.sh; if [ "$1" == "launchd" ]; then java -Xms1024M -classpath $CLASSPATH luan.Luan run_host.luan logs 1>logs/stdout.log 2>logs/stderr.log
--- a/host/start_nginx.sh Thu Jan 15 21:30:07 2026 -0800 +++ b/host/start_nginx.sh Fri Jan 16 15:30:49 2026 -0800 @@ -1,3 +1,3 @@ #!/bin/bash -sudo $(which nginx) -c $(pwd)/local/nginx.conf; +sudo nginx;
--- a/host/startup/nginx/nginx.conf.luan Thu Jan 15 21:30:07 2026 -0800 +++ b/host/startup/nginx/nginx.conf.luan Fri Jan 16 15:30:49 2026 -0800 @@ -1,30 +1,13 @@ local rootDir, user, group = ... %> -worker_processes 4; -user <%=user%> <%=group%>; -pid /var/run/luanhost_nginx.pid; - -events { - worker_connections 4096; -} - -http { - include mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - - proxy_cache_path <%=rootDir%>/local/nginx_cache levels=1:2 keys_zone=nginx_cache:60m max_size=10g inactive=60m use_temp_path=off; - - upstream luan { - server 127.0.0.1:8080; - } - + proxy_cache_path /usr/local/nginx_cache levels=1:2 keys_zone=nginx_cache:60m max_size=10g inactive=60m use_temp_path=off; server { + # ensure no other default_server exists! + # nginx usually has one at /etc/nginx/sites-enabled/default listen 80 default_server; listen [::]:80 default_server; - include nginx.default.conf; + include <%=rootDir%>/local/nginx.default.conf; location /.well-known/acme-challenge/ { # $host/ssl does not exist for non-ssl sites and requests to here @@ -37,5 +20,4 @@ # glob pattern returns no results for site dirs that don't have # the ssl/ subdir, so this is ok include <%=rootDir%>/sites/*/ssl/nginx.ssl.conf; -} <%
--- a/host/startup/nginx/nginx.default.conf.luan Thu Jan 15 21:30:07 2026 -0800 +++ b/host/startup/nginx/nginx.default.conf.luan Fri Jan 16 15:30:49 2026 -0800 @@ -25,6 +25,6 @@ proxy_cache_lock on; add_header X-Cache-Status $upstream_cache_status; proxy_read_timeout 24h; - proxy_pass http://luan; + proxy_pass http://127.0.0.1:8080; } <%
--- a/host/stop.sh Thu Jan 15 21:30:07 2026 -0800 +++ b/host/stop.sh Fri Jan 16 15:30:49 2026 -0800 @@ -30,5 +30,5 @@ echo "no running app found"; fi; -sudo $(which nginx) -s stop -c $(pwd)/local/nginx.conf; +./stop_nginx.sh; exit 0;
--- a/host/stop_nginx.sh Thu Jan 15 21:30:07 2026 -0800 +++ b/host/stop_nginx.sh Fri Jan 16 15:30:49 2026 -0800 @@ -1,3 +1,3 @@ #!/bin/bash -sudo $(which nginx) -s stop -c "$(pwd)/local/nginx.conf"; +sudo nginx -s stop;
--- a/host/update2.sh Thu Jan 15 21:30:07 2026 -0800 +++ b/host/update2.sh Fri Jan 16 15:30:49 2026 -0800 @@ -13,13 +13,13 @@ openssl genrsa 4096 >local/tiny_account.key fi -cp startup/nginx/mime.types local/mime.types # id -gn gets the name of the primary group of the current user (staff) luan startup/nginx/nginx.conf.luan $(pwd) $(whoami) $(id -gn) >local/nginx.conf luan startup/nginx/nginx.default.conf.luan $(pwd) >local/nginx.default.conf # this is done because the nginx conf uses absolute paths # and this breaks sites when the luan/host directory is moved +# NOTE: if the luanhost root dir changes, the nginx include needs to be manually updated to reflect the new path. luan classpath:luan/host/update.luan echo Starting...
--- a/src/luan/host/Https.luan Thu Jan 15 21:30:07 2026 -0800 +++ b/src/luan/host/Https.luan Fri Jan 16 15:30:49 2026 -0800 @@ -99,8 +99,8 @@ ssl_certificate <%= files.local_cer_file.to_string() %>; ssl_certificate_key <%= files.key_file.to_string() %>; - # path is relative to the dir of the conf this comment is found in. - include nginx.default.conf; + # path is relative to the dir of the master nginx conf + include <%=luanhost_dir.canonical().to_string()%>/local/nginx.default.conf; # allow users to upload custom nginx.*.conf files, e.g. for mixpanel include <%=luanhost_dir.canonical().to_string()%>/sites/<%=domain%>/site/nginx.*.conf; }
