This repo contains specific patches to avoid brief 502 Gateway Problem when NGINX reloads.
It works, but leaves PassengerAgent leaks over time because the reap function is commented out. To solve it, you need to put the cleanup script in the cronjob.
This will builds NGINX from source. To make it more performant. We also add LibreSSL + HTTP v3 build.
First, check if you has Ruby, if not then install it using RVM
curl -sSL https://get.rvm.io | bash -s head --ruby
source~/.rvm/scripts/rvm
gem install json rack rakeOr Ubuntu APT
sudo apt install ruby ruby-dev ruby-json ruby-rack rakemake allgit clone https://github.com/domcloud/nginx-builder/ /usr/local/lib/nginx-builder
cd /usr/local/lib/nginx-builder/
make install
# At this step, remove system nginx# Rewrite custom NGINX service
cat <<'EOF' > /usr/lib/systemd/system/nginx.service[Unit]Description=The nginx HTTP and reverse proxy serverAfter=network-online.target remote-fs.target nss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/run/nginx.pid# Nginx will fail to start if /run/nginx.pid already exists but has the wrong# SELinux context. This might happen when running `nginx -t` from the cmdline.# https://bugzilla.redhat.com/show_bug.cgi?id=1268621ExecStartPre=/usr/bin/rm -f /run/nginx.pidExecStartPre=/usr/local/sbin/nginx -tExecStart=/usr/local/sbin/nginxExecReload=/usr/local/sbin/nginx -s reloadKillSignal=SIGQUITTimeoutStopSec=5KillMode=mixedPrivateTmp=true[Install]WantedBy=multi-user.targetEOF
systemctl daemon-reload
# Retain compatibilty with many tools
ln -s /usr/local/sbin/nginx /usr/sbin/nginxThen in the NGINX configuration add
passenger_root /usr/local/lib/nginx-builder/passenger;
passenger_ruby /usr/bin/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;