The EasyApache 4 Dilemma: Why Nginx Lacks Lua
ea-nginx), designed for predictable updates, compatibility, and seamless integration with Apache backend handlers. Because cPanel maintains strict control over the RPM repository, core packages are stripped of non-standard third-party dynamic modules like 'ngx_http_lua_module' to maintain stability, security baselines, and straightforward dependency trees.
When administrators attempt to install standard Lua-based applications or custom OpenResty stacks directly over the system Nginx, they inevitably hit a brick wall. Package managers override binaries during routine EA4 updates, wiping out custom compilations and abruptly taking down production routing layers.
Architectural Strategy: Coexistence vs. Replacement
ea-nginx RPM. Instead, we compile a standalone OpenResty instance optimized for edge routing, leaving EA4 untouched to handle local virtual host configurations and PHP-FPM socket generation.
Step 1: Preparing the Build Environment
yum groupinstall 'Development Tools' -y
yum install pcre-devel openssl-devel zlib-devel readline-devel perl-devel make -yStep 2: Downloading and Compiling OpenResty
cd /usr/local/src
wget https://openresty.org/download/openresty-1.21.4.2.tar.gz
tar -zxvf openresty-1.21.4.2.tar.gz
cd openresty-1.21.4.2
./configure \
--prefix='/opt/openresty' \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-threads \
--with-luajit
make -j$(nproc)
make installIntegrating OpenResty as the Primary Edge Proxy
Sample OpenResty Edge Configuration
worker_processes auto;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
lua_shared_dict ratelimit_cache 10m;
server {
listen 80;
server_name example.com;
location / {
access_by_lua_block {
local limit = ngx.shared.ratelimit_cache
local ip = ngx.var.remote_addr
local current, err = limit:get(ip)
if current then
if current > 100 then
ngx.exit(503)
end
limit:incr(ip, 1)
else
limit:set(ip, 1, 60)
end
}
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}Automating Persistence Across cPanel Updates
[Unit]
Description=OpenResty High-Performance Web Platform
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/openresty/nginx/logs/nginx.pid
ExecStart=/opt/openresty/bin/openresty -g 'daemon on;'
ExecReload=/opt/openresty/bin/openresty -s reload
ExecStop=/opt/openresty/bin/openresty -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl enable openresty
systemctl start openresty