lua-io-nginx-module-plus

Note: OpenResty 1.21.4.3 or higher is required for this library. The use must have the root permission.

Note: OpenResty 1.21.4.3 or higher is required for this library.

Prerequisites

  • The use must have the root permission.

  • The machine needs to be able to access the following domains to download packages and GPG keys:

    You can check the accessibility of the domains by running the following commands:

    curl https://openresty.org/package/pubkey.gpg
    curl https://pkg2.openresty.com/xray-priv-libs/
    

Configure the software repository

First, we need to configure the repository of the binary installer using the commands below. (The CLIENT_TOKEN in the commands needs to be replaced with a valid Token from the subscription email)

curl -o get-xray-priv-lib-repo.sh https://pkg2.openresty.com/scripts/get-xray-priv-lib-repo.sh
sudo bash get-xray-priv-lib-repo.sh -l lua-io-nginx-module-plus -t CLIENT_TOKEN

Installation

For OpenResty-1.21.4.x

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.21.4

For operating systems such as Fedora that use dnf as package manager, execute the following command to install the private library.

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.21.4

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get install -y lua-io-nginx-module-plus-1.21.4

For OpenResty 1.25.3.x

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.25.3

For operating systems such as Fedora that use dnf as package manager, execute the following command to install the private library.

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.25.3

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get install -y lua-io-nginx-module-plus-1.25.3

For OpenResty 1.27.1.x

For systems using the yum package manager, run the following commands to install the private library:

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.27.1

For systems using the dnf package manager, run the following commands to install the private library:

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.27.1

For systems using the apt package manager, run the following command to install the private library:

sudo apt-get install -y lua-io-nginx-module-plus-1.27.1

For OpenResty 1.31.8.x

For systems using the yum package manager, run the following commands to install the private library:

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.31.8

For systems using the dnf package manager, run the following commands to install the private library:

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf install --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.31.8

For systems using the apt package manager, run the following command to install the private library:

sudo apt-get install -y lua-io-nginx-module-plus-1.31.8

Upgrade

For OpenResty-1.21.4.x

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.21.4

For operating systems such as Fedora that use dnf as package manager, execute the following command to install the private library.

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.21.4

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get update
sudo apt-get install -y lua-io-nginx-module-plus-1.21.4

For OpenResty 1.25.3.x

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.25.3

For operating systems such as Fedora that use dnf as package manager, execute the following command to install the private library.

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.25.3

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get update
sudo apt-get install -y lua-io-nginx-module-plus-1.25.3

For OpenResty 1.27.1.x

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.27.1

For operating systems such as Fedora that use dnf as package manager, execute the following command to install the private library.

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"  -y lua-io-nginx-module-plus-1.27.1

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get update
sudo apt-get install -y lua-io-nginx-module-plus-1.27.1

For OpenResty 1.31.8.x

For systems using the yum package manager, run the following commands to upgrade the private library:

sudo yum makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo yum update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.31.8

For systems using the dnf package manager, run the following commands to upgrade the private library:

sudo dnf makecache --disablerepo="*" --enablerepo="lua-io-nginx-module-plus"
sudo dnf update --disablerepo="*" --enablerepo="lua-io-nginx-module-plus" -y lua-io-nginx-module-plus-1.31.8

For systems using the apt package manager, run the following command to upgrade the private library:

sudo apt-get update
sudo apt-get install -y lua-io-nginx-module-plus-1.31.8

Installing OpenResty

When installing or upgrading OpenResty, first query the available versions and install the version that matches the selected private library. Avoid upgrading directly to the latest repository version, which may be incompatible with the installed dynamic modules.

Configure the OpenResty repository as described in https://openresty.org/en/linux-packages.html.

For example, on systems using yum as the package manager, to install OpenResty 1.25.3:

$ yum list --showduplicates openresty
Last metadata expiration check: 0:07:22 ago on Sat 13 Sep 2025 07:15:05 AM CST.
Available Packages
openresty.x86_64                                                      1.21.4.4-1.el9                                                      openresty
openresty.x86_64                                                      1.25.3.2-1.el9                                                      openresty
openresty.x86_64                                                      1.27.1.2-1.el9                                                      openresty
$ sudo yum install openresty-1.25.3.2-1.el9

For example, on systems using dnf as the package manager, to install OpenResty 1.25.3:

$ dnf list --showduplicates openresty
Last metadata expiration check: 0:07:22 ago on Sat 13 Sep 2025 07:15:05 AM CST.
Available Packages
openresty.x86_64                                                      1.21.4.4-1.el9                                                      openresty
openresty.x86_64                                                      1.25.3.2-1.el9                                                      openresty
openresty.x86_64                                                      1.27.1.2-1.el9                                                      openresty
$ sudo dnf install openresty-1.25.3.2-1.el9

For systems using apt as the package manager, to install OpenResty 1.25.3:

$ apt-cache madison openresty
 openresty | 1.27.1.2-1~noble1 | https://openresty.org/package/ubuntu noble/main amd64 Packages
 openresty | 1.27.1.1-1~noble1 | https://openresty.org/package/ubuntu noble/main amd64 Packages
 openresty | 1.25.3.2-2~noble1 | https://openresty.org/package/ubuntu noble/main amd64 Packages

$ sudo apt install openresty=1.25.3.2-2~noble1

Usage

Nginx configuration

Before you can use lua-io-nginx-module-plus, you need to add the following configuration items to the configuration file nginx.conf to load the related dynamic modules.

# The load_module directive must be on top of nginx.conf
load_module /usr/local/openresty/nginx/modules/ngx_http_lua_io_module.so;

thread_pool default threads=2 max_queue=10;
...


http {
    location /ngx_io {
        content_by_lua_block {
            local ngx_io = require "ngx.io"

            local file, err = ngx_io.open("/tmp/foo.txt", "w")
            if not file then
                ngx.log(ngx.ERR, "failed to open /tmp/foo.txt: ", err)
                return
            end

            local bytes, err = file:write("hello world\n")
            if err ~= nil then
                ngx.log(ngx.ERR, "failed to write: ", err)
                -- fall through
            end

            local ok, err = file:close()
            if err ~= nil then
                ngx.log(ngx.ERR, "failed to close: ", err)
                return
            end

        }
    }
}