Neko Docs

Nginx

Install

编译安装最新版 (with_stream)

#!/bin/bash
apt update && apt install -y nginx
apt install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev libgd-dev libxml2 libxml2-dev uuid-dev
wget https://nginx.org/download/nginx-1.29.0.tar.gz
tar -xf nginx-1.29.0.tar.gz
cd nginx-1.29.0/
./configure --prefix=/var/www/html --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --with-pcre  --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-http_ssl_module --with-http_image_filter_module=dynamic --modules-path=/etc/nginx/modules --with-http_v2_module --with-stream=dynamic --with-http_addition_module --with-http_mp4_module --with-stream_ssl_preread_module --with-stream_ssl_module
make
make install
apt-mark hold nginx* libnginx*
wget f.neko.sbs/nginx.conf -O /etc/nginx/nginx.conf
 
cat > /usr/lib/systemd/system/nginx.service << EOF
[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed
 
[Install]
WantedBy=multi-user.target
EOF
 
systemctl daemon-reload
systemctl restart nginx

HTTPS / SSL

certbot

apt install certbot python3-certbot-nginx -y

编辑 /etc/nginx/conf.d/<domain>.conf

certbot --nginx -d <domain>

检查 /etc/nginx/conf.d/<domain>.conf

检查配置并重启nginx

nginx -t && nginx -s reload

On this page