准确的说是, 可运行在内核2.6+, libc 2.7+的所有Linux x64系统上.
https://otfiles.otherhill.com:12321/uploads/file/20211215/chroot_jail2021_x64.tar.gz (61 MB)下载后,直接解压到/opt, 最终目录结构如下:

我们需要创建用户nginx, 以及组nginx.
#-M表示不创建home目录.
sudo useradd -s /sbin/nologin -M nginx
Linux上的应用, 一般想要打开低于1024的端口,都需要root权限.
因为nginx要管理80,443,等低端口. 所以一般都以root权限运行.但这样不太安全.
让nginx 以一般用户权限,运行于低端口的方法是:
setcap cap_net_bind_service=ep /opt/nginx/sbin/nginx
or
usermod -aG sudo,nginx nginx
# The -a option tells usermod we are appending and the -G option tells usermod we are appending to the group name that follows the option.
验证用户和组是否创建成功:
sudo id nginx
#验证下加组结果:
cat /etc/group
or
sudo grep nginx /etc/passwd /etc/group
查看nginx的配置文件nginx.conf的位置并验证其语法错误:
/opt/chroot_jail/opt/nginx/sbin/nginx -t
/opt/chroot_jail/opt/nginx/sbin/nginx -c your_nginx.conf
完成以上配置后, 运行
sudo -u nginx /opt/chroot_jail/opt/nginx/sbin/run.sh, 即可.
使用/opt/chroot_jail/opt/nginx/sbin/run.sh脚本的话, nginx可能会报host name not found.
或者报 getpwnam() failed错误:

解决办法就是, 让nginx运行于chroot之中:
sudo chroot ./
cd opt/nginx/sbin
./run.sh
退出chroot
./run.sh -s stop
exit

因为采用最新的openssl-1.1.1m, 以及nginx-1.21.3源码编译, 所以支持TLS 1.3, 以及TLS SNI.
压缩包自带测试网站.

配置中常见错误及解决办法:
nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (2: No such file or directory)
解决方法:
[root@localhost sbin]# mkdir -p /var/cache/nginx/client_temp