Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] add lua support #500

Open
1 task done
pickworth opened this issue Aug 20, 2024 · 6 comments
Open
1 task done

[FEAT] add lua support #500

pickworth opened this issue Aug 20, 2024 · 6 comments
Labels
enhancement New feature or request no-issue-activity

Comments

@pickworth
Copy link

Is this a new feature request?

  • I have searched the existing issues

Wanted change

lua is good for writing custom logic in the webservers

Reason for change

I've tried putting /usr/lib/nginx/modules/ngx_http_lua_module.so
but that doesn't work. I'm assuming the modules are not setup to auto load and need to recompile nginx.

so.. currently I need to run
apk update && apk add nginx-mod-http-lua every time the container is built, which is a bit annoying when it needs to update.

I understand I can add it to the RUN command, but that would replace the intented command in the Dockerfile

Proposed code change

just simply apk add nginx-mod-http-lua

Thanks :)

@pickworth pickworth added the enhancement New feature or request label Aug 20, 2024
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@aptalca
Copy link
Member

aptalca commented Aug 20, 2024

@pickworth
Copy link
Author

@aptalca
Ohh that's fancy! had my hopes up for a while, but unfortunately this seems broken

nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
...

root@6785fb4cc8f8:/# apk info -vv | grep nginx-mod-http-lua
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.14/main: No such file or directory
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.14/community: No such file or directory

root@d62e9aad05f0:/# cat /mod-repo-packages-to-install.list
cat: /mod-repo-packages-to-install.list: No such file or directory
root@d62e9aad05f0:/#

try manually paste the relevant script from the repo to so what it does....

root@d62e9aad05f0:/# 
INSTALL_PACKAGES=nginx-mod-http-lua

#Split list of packages on delimiter '|'
IFS='|'
INSTALL_PACKAGES=(${INSTALL_PACKAGES})
for PKG in "${INSTALL_PACKAGES[@]}"; do
    echo "**** Adding ${PKG} to OS package install list ****"
    echo "${PKG}" >> /mod-repo-packages-to-install.list
done

**** Adding nginx-mod-http-lua to OS package install list ****

root@d62e9aad05f0:/# cat /mod-repo-packages-to-install.list
nginx-mod-http-lua

its there now.. lets reboot and see what happens .

nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[mod-init] Attempting to run Docker Modification Logic
[mod-init] Applying linuxserver/mods:universal-package-install files to container
[mod-init] linuxserver/mods:universal-package-install at sha256:179666823e425c84f903183aa0b76eb4fe6ce386fdeb55ca85b56b7791669140 has been previously applied skipping
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing... 
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 02-tamper-check: executing... 
[cont-init.d] 02-tamper-check: exited 0.
[cont-init.d] 10-adduser: executing... 
usermod: no changes

.... snipped ...

[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
Server ready
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25

nope, still nothing..

root@d62e9aad05f0:/# apk list nginx-mod-http-lua
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.14/main: No such file or directory
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.14/community: No such file or directory

ok.. manual install time...

root@d62e9aad05f0:/# apk add nginx-mod-http-lua
fetch http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/4) Installing luajit (2.1_p20210510-r0)
(2/4) Installing lua-resty-lrucache (0.09-r1)
(3/4) Installing lua-resty-core (0.1.21-r0)
(4/4) Installing nginx-mod-http-lua (1.20.2-r1)
Executing busybox-1.33.1-r6.trigger
OK: 259 MiB in 232 packages

root@d62e9aad05f0:/# apk list nginx-mod-http-lua
nginx-mod-http-lua-1.20.2-r1 x86_64 {nginx} (BSD-2-Clause) [installed]
root@d62e9aad05f0:/#

restart container again..

[cont-init.d] 99-custom-files: executing... 
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Server ready

^ lua_need_request_body in my config is now recognised and server starts fine now.

wipe cache layers and rebuild again and problem is back:

[cont-init.d] 99-custom-files: executing... 
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Server ready
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25

try this time with INSTALL_PACKAGES="luajit|lua-resty-lrucache|lua-resty-core|nginx-mod-http-lua"
(these should have already been pulled in when running apk add nginx-mod-http-lua)

still no dice

[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Server ready
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25
nginx: [emerg] unknown directive "lua_need_request_body" in /config/nginx/proxy-confs/dockerregistry.subdomain.conf:25

the log lines here are a bit suspicious, because i had never used mods before:

[mod-init] Attempting to run Docker Modification Logic
[mod-init] Applying linuxserver/mods:universal-package-install files to container
[mod-init] linuxserver/mods:universal-package-install at sha256:179666823e425c84f903183aa0b76eb4fe6ce386fdeb55ca85b56b7791669140 has been previously applied skipping

here's the docker run command, maybe there's something special here breaking it?

docker run \
  -d \
  --name='swag' \
  --net='bond0.10' \
  --ip='10.x.x.x' \
  --cpuset-cpus='3,4,5,7' \
  -e TZ="Australia/Sydney" \
  -e HOST_OS="Unraid" \
  -e HOST_HOSTNAME="myservername" \
  -e HOST_CONTAINERNAME="swag" \
  -e 'TCP_PORT_443'='443' \
  -e 'TCP_PORT_80'='80' \
  -e 'URL'='redacted-singlename.com' \
  -e 'VALIDATION'='dns' \
  -e 'SUBDOMAINS'='redacted-singlename' \
  -e 'CERTPROVIDER'='' \
  -e 'DNSPLUGIN'='google' \
  -e 'PROPAGATION'='' \
  -e 'DUCKDNSTOKEN'='' \
  -e 'EMAIL'='[email protected]' \
  -e 'ONLY_SUBDOMAINS'='true' \
  -e 'EXTRA_DOMAINS'='big,redacted,list,of,domains,here.com' \
  -e 'STAGING'='false' \
  -e 'DOCKER_MODS'='linuxserver/mods:universal-package-install' \
  -e 'INSTALL_PACKAGES'='nginx-mod-http-lua' \
  -e 'PUID'='99' \
  -e 'PGID'='100' \
  -e 'UMASK'='022' \
  -v '/mnt/user/appdata/letsencrypt-archive':'/config/etc/letsencrypt/archive':'rw' \
  -v '/mnt/user/appdata/swag/modules':'/var/lib/nginx/modules':'rw' \
  -v '/mnt/user/appdata/swag':'/config':'rw' \
  --cap-add=NET_ADMIN 'lscr.io/linuxserver/swag' 

@aptalca
Copy link
Member

aptalca commented Aug 20, 2024

You're on a super old image. SWAG is on alpine 3.20, your image is on 3.14, that's a 3 year difference at a minimum.

Pull the latest image first.

@thespad
Copy link
Member

thespad commented Aug 20, 2024

You might also need additional lua packages to support it, such as these

@LinuxServer-CI
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no-issue-activity
Projects
Status: Issues
Development

No branches or pull requests

4 participants